web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

closed case

(0) ShareShare
ReportReport
Posted on by

i want to close the case but it doesnt seem work.
try
{
trace.Trace("inside try");
Entity target = (Entity)context.InputParameters["target"];
//retrieve
Entity entity = service.Retrieve("task", target.Id, new ColumnSet(true));
//pointer
EntityReference regardingCaseRef = entity["regardingobjectid"] as EntityReference;
Entity regardingCase = service.Retrieve(regardingCaseRef.LogicalName, regardingCaseRef.Id, new ColumnSet(true));
//retrieve multiple using query expression
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);

if (AllTaskReject(relatedTasks))

{
trace.Trace("insidebool");
Entity IncidentResolution = new Entity("incidentresolution");
IncidentResolution.Attributes["subject"] = "Incident Resolved";
IncidentResolution.Attributes["incidentid"] = new EntityReference("incident", entity.Id);
CloseIncidentRequest closeRequest = new CloseIncidentRequest();
closeRequest.IncidentResolution = IncidentResolution;
closeRequest.Status = new OptionSetValue(912450000);
// Execute the close request
service.Execute(closeRequest);
//trace.Trace("status check");
//regardingCase["cos_csucasestatus"] = new OptionSetValue(769190006);
//trace.Trace("status check 2");

//service.Update(regardingCase);
//trace.Trace("status check 3");
/* Entity incident = new Entity("incident");
incident.Id = regardingCaseRef.Id;
trace.Trace("1");
incident["cos_csucasestatus"] = new OptionSetValue(769190006);
service.Update(incident);*/
// regardingCase.Attributesk["cos_csucasestatus"] = new OptionSetValue(769190006);
}

}
catch
{
throw;
}

}

}
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.ToEntity<Task>().cos_CSUTaskStatus == cos_CSUTaskStatus.Rejected))
{

return true;
}
else
{
return false;
}

I have the same question (0)
  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator on at

    Hi,

    What is the error you are getting?

    Did you check plugin trace logs?

    Did you try to debug your plugin code?

  • Community Member Profile Picture
    on at

    An error occurred in the plug-in.

    yes its only go to the if, it doesnt go inside.i have  tried so many ways but cant find what wrong with its

  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator on at

    Hi,

    Possible values for Incident Resolution Status field

    StatusCode Choices/Options

    Value Label State

    1 Open 0

    2 Closed 1

    3 Canceled 2

    But in your code you are passing 912450000. This is incorrect. Please recheck once

  • Community Member Profile Picture
    on at

    oh i see one more thing in the pluggin  i set up like this

    message create

    primary incidentresolution

    is this correct

  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator on at

    Hi,

    Primary Entity should be Task.

  • Community Member Profile Picture
    on at

    try
    {
    trace.Trace("inside try");
    Entity target = (Entity)context.InputParameters["target"];
    //retrieve
    Entity entity = service.Retrieve("task", target.Id, new ColumnSet(true));
    //pointer
    EntityReference regardingCaseRef = entity["regardingobjectid"] as EntityReference;
    Entity regardingCase = service.Retrieve(regardingCaseRef.LogicalName, regardingCaseRef.Id, new ColumnSet(true));
    //retrieve multiple using query expression
    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("updatestatuscode");
    if (AllTaskReject(relatedTasks))

    {
    Hi im new to crm how can i update the status code of the incident

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    I would highly recommend starting using Search Engines to find answers to questions that were asked already multiple times.

    mscrmtechie.blogspot.com/.../resolve-and-cancel-cases-in-crmdynamics.html

    softchief.com/.../

    And please, stop creating duplicated threads.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 170 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 61

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 52 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans