Hello,
Below is part of my code. I know why I am getting this error, what I need is a workaround or a solution to this problem.
Thank you.
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity) { Entity Case = (Entity)context.InputParameters["Target"]; IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory)); IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId); try { string serialNumber = ""; if (Case.GetAttributeValue("zst_serialnumber") != null) { serialNumber = Case.GetAttributeValue("zst_serialnumber").Id.ToString(); //serial number is a lookup field } Entity Warranty = new Entity("zst_warranty"); QueryExpression query = new QueryExpression("zst_warranty"); query.ColumnSet = new ColumnSet(new string[] { "zst_name" }); query.Criteria.AddCondition("zst_serialno", ConditionOperator.Equal, serialNumber); //zst_serialno is a lookup field EntityCollection collection = service.RetrieveMultiple(query); if (collection.Entities.Count > 0) { Case["zst_activewarranty"] = true; } else if (collection.Entities.Count == 0) { Case["zst_activewarranty"] = false; } service.Update(Case); }