Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

closed case

Posted on by Microsoft Employee

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;
}

  • a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: update the statuscode

    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.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    update the statuscode

    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

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: closed case

    Hi,

    Primary Entity should be Task.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: closed case

    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
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: closed case

    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
    Community Member Microsoft Employee on at
    RE: closed case

    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
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: closed case

    Hi,

    What is the error you are getting?

    Did you check plugin trace logs?

    Did you try to debug your plugin code?

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans