Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

Update an active record to inactive

$
0
0

Hi all,

I have an entity with active and inactive records. I want to update the state of the record(from active to inactive).

For this I have written the code:

public  static void CheckIfInworkActions(ICrmContext context)
        {
           QueryExpression exe= new QueryExpression(avd_agenthandlingtime.EntityLogicalName);

       exe.ColumnSet.AddColumn(XrmAttributes.AgentHandlingTime.statecode);
            exe.Criteria.AddCondition(XrmAttributes.StateCode, ConditionOperator.Equal, 0);
          

            var coll1 = context.OrganizationService.RetrieveMultiple(exe);

            foreach (Entity e in coll1.Entities)
            {
                if (coll1 != null && coll1.Entities != null && coll1.Entities.Count > 0)
                {
                   e.Attributes["statecode"] = new OptionSetValue((int)1);

                    context.OrganizationService.Update(e);

                }


            }

        }

can any one suggest me where I am going wrong?


Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>