how can i update the Satisfaction. In the incident case form i have case status
if the case status = complete
=>> Satisfaction will be sastisfied
try
{
trace.Trace("insidetry");
Entity incident = (Entity)context.InputParameters["Target"];
Entity entity = service.Retrieve("incident", incident.Id, new ColumnSet(true));
//chi nhan nhung cot bi thay doi
trace.Trace("case");
EntityReference RegardingCaseRef = entity["cos_csucasestatus"] as EntityReference;
Entity RegardingCase = service.Retrieve(RegardingCaseRef.LogicalName, RegardingCaseRef.Id, new ColumnSet("cos_csucasestatus"));
// inherited from the QueryBase,
trace.Trace("incident");
QueryExpression qeCaseStatus = new QueryExpression("incident");
qeCaseStatus.ColumnSet = new ColumnSet(true);
qeCaseStatus.Criteria.AddCondition(new ConditionExpression("cos_csucasestatus", ConditionOperator.Equal, RegardingCaseRef.Id));
EntityCollection allRelatedCase = service.RetrieveMultiple(qeCaseStatus);
trace.Trace("check boool");
if (CheckcaseStatus(allRelatedCase))
{
trace.Trace("Case title: " + RegardingCase["title"]);
RegardingCase["customersatisfactioncode"] = new OptionSetValue(5);
service.Update(RegardingCase);
}
}
catch
{
throw;
}
}
}
public bool CheckcaseStatus (EntityCollection CaseStatus)
{
if (CaseStatus.Entities.All(x => x.GetAttributeValue<OptionSetValue>("cos_csucasestatus")?.Value == 769190006))
{
//Console.WriteLine("All task completed");
return true;
}
else
{
return false;
}