Scenario:I have an option set with options "Inwork,pause,complete". value of inwork is 100000004, value of pause is 100000011.
I have an entity avd_masteraction with so many records. I have to retrive all the records from the entity, if any of the records is in inwork state ,i have to update the field to pause. I wrote the below code to update the field but I am getting the below error. Can any one tell where I am exactly missing?
private void CheckIfInworkActions(ICrmContext context,Guid userId)
{
QueryExpression exe1 = new QueryExpression(avd_masteraction.EntityLogicalName);
exe1.ColumnSet.AddColumn(XrmAttributes.MasterAction.Status);
exe1.Criteria.AddCondition(XrmAttributes.StatusCode, ConditionOperator.Equal, 100000004);
var coll1 = context.OrganizationService.RetrieveMultiple(exe1);
foreach (Entity e in coll1.Entities)
{
if (coll1 != null && coll1.Entities != null && coll1.Entities.Count > 0)
{
if (e.LogicalName=="avd_masteraction")
{
e.Attributes["statuscode"] = "100000011";
}
context.OrganizationService.Update(e);
}
}
}