Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Answered

how to update csu case status

Posted on by Microsoft Employee

how do i update CSu case status

try
{
trace.Trace("inside try");
//obtain the target entity from the inputparameter
Entity target = (Entity)context.InputParameters["Target"];
//rettrive
trace.Trace("retrieve task");
Entity entity = service.Retrieve("task", target.Id, new ColumnSet(true));

EntityReference regardingCaseRef = entity["regardingobjectid"] as EntityReference;
//retrive regarding from the back end
trace.Trace("2");
Entity regardingCase = service.Retrieve(regardingCaseRef.LogicalName, regardingCaseRef.Id, new ColumnSet(true));
//retrieve entityrecord from the ms crm server that match the
trace.Trace("4");
QueryExpression qeRelatedTasks = new QueryExpression("task");
qeRelatedTasks.ColumnSet = new ColumnSet(true);
qeRelatedTasks.Criteria.AddCondition(new ConditionExpression("regardingobjectid", ConditionOperator.Equal, regardingCaseRef.Id));
EntityCollection relatedTasks = service.RetrieveMultiple(qeRelatedTasks);
trace.Trace("check bool");
if (AllTaskReject(relatedTasks))
{
//resovle the case
update regarding case status
}

}
catch (FaultException ex)
{
throw new InvalidPluginExecutionException("An error occurred in the plug-in.", ex);
}

}

public bool AllTaskReject(EntityCollection relatedTasks)
{
//check all the the task if rejected continue if on task not rejected do nothing

if (relatedTasks.Entities.All(x => x.GetAttributeValue<OptionSetValue>("cos_csutaskstatus")?.Value == 769190003))
{

return true;
}
else
{
return false;
}
}

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: how to update csu case status

    Hi,

    You need to use below code to set multi choice optionset field

    OptionSetValueCollection collectionOptionSetValues = new OptionSetValueCollection();

    OptionSetValue optionSet = new OptionSetValue(optionsetValue);

    collectionOptionSetValues.Add(optionSet);

    entityAccount["new_multioption"] = collectionOptionSetValues;

    _service.Update(entityAccount);

    www.inogic.com/.../

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: how to update csu case status

    its still not work i even try   regardingCase["cos_csucasestatus"]

  • Verified answer
    Bipin D365 Profile Picture
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: how to update csu case status

    Hi,

    Please try below code to update Case status.

    Entity incident=new Entity("incident");

    incident.Id=regardingCase I'd;

    incident["casestatusfieldname"]= new optionSetValue(Enter Rejected status value);

    service.Update(incident);

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: how to update csu case status

    No duplicated threads, please.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    how to resolve case after that csu case change to reject

    i have this code when task rejected and resolve the case the csu case status will be reject

    try
    {
    trace.Trace("inside try");
    //obtain the target entity from the inputparameter
    Entity target = (Entity)context.InputParameters["Target"];
    //rettrive
    trace.Trace("retrieve task");
    Entity entity = service.Retrieve("task", target.Id, new ColumnSet(true));

    EntityReference regardingCaseRef = entity["regardingobjectid"] as EntityReference;
    //retrive regarding from the back end
    trace.Trace("2");
    Entity regardingCase = service.Retrieve(regardingCaseRef.LogicalName, regardingCaseRef.Id, new ColumnSet(true));
    //retrieve entityrecord from the ms crm server that match the
    trace.Trace("4");
    QueryExpression qeRelatedTasks = new QueryExpression("task");
    qeRelatedTasks.ColumnSet = new ColumnSet(true);
    qeRelatedTasks.Criteria.AddCondition(new ConditionExpression("regardingobjectid", ConditionOperator.Equal, regardingCaseRef.Id));
    EntityCollection relatedTasks = service.RetrieveMultiple(qeRelatedTasks);
    trace.Trace("check bool");
    if (AllTaskReject(relatedTasks))
    {
    //resovle the case
    //769190006 //create an incident
    trace.Trace("create incident");
    Entity IncidentResolution = new Entity("incidentresolution");
    IncidentResolution.Attributes["subject"] = "Subject Closed";
    trace.Trace("inheritance");
    //Inheritance OBJECT
    IncidentResolution.Attributes["incidentid"]= new EntityReference("incident",entity.Id);
    IncidentResolution.Attributes["cos_csucasestatus"] = new OptionSetValue(806570002);
    service.Update(IncidentResolution);
    }

    }
    catch (FaultException ex)
    {
    throw new InvalidPluginExecutionException("An error occurred in the plug-in.", ex);
    }

    }

    public bool AllTaskReject(EntityCollection relatedTasks)
    {
    //check all the the task if rejected continue if on task not rejected do nothing

    if (relatedTasks.Entities.All(x => x.GetAttributeValue<OptionSetValue>("cos_csutaskstatus")?.Value == 769190003))
    {

    return true;
    }
    else
    {
    return false;
    }
    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans