locked
Case resolution RRS feed

  • Question

  • Hi,
    I am having a custom button in case form as "Resolve Case",Now if i click the button i need to resolve the case with subject completed.How to acheive this.Can i change the status of the case inside javascript.What is the solution.

     

    Thanks

    Divya

    Thursday, February 18, 2010 2:02 AM

Answers

All replies

  • Hi, use the SetStateIncident Message to change the state of the incident.

    // Create the Request Object
    SetStateIncidentRequest state = new SetStateIncidentRequest();

    // Set the Request Object's Properties
    state.IncidentState = IncidentState.Resolved;
    state.IncidentStatus= 5;

    // EntityId is the Guid of the incident whose state is being changed
    state.EntityId = new Guid("AD618DB2-F0DB-4A6A-8C4B-2F2213EAA38E");;

    // Execute the Request
    SetStateIncidentResponse stateSet = (SetStateIncidentResponse)service.Execute(state);

    you have to convert the about code in to javascript and call it from teh "ISV config" custom button.
    here is a tool that can help you convert from C# to javsacript.
    http://www.stunnware.com/crm2/topic.aspx?id=jswebservice2

    Thursday, February 18, 2010 3:31 AM
  • Hi ,
    I am not able to convert it through the tool of stunware.Please can u provide me the converted code.

    Thanks

    Divya
    Thursday, February 18, 2010 4:03 AM
  • Hi Divya,
    my mistake, you have to use "CloseIncidentRequest" message to close the incident, here is teh C# code. now you should be able to get the actual code.



    incidentresolution activity = new incidentresolution();
       activity.incidentid = new Lookup();
       activity.incidentid.type = EntityName.incident.ToString();
       activity.incidentid.Value = new Guid("E16A2B61-539B-DE11-94EE-0003FFFEFFFF"); // guid of the incident
       activity.subject = "subject";

       try
       {
        service.Create(activity);              

        CloseIncidentRequest closeJob = new CloseIncidentRequest();
        closeJob.IncidentResolution = activity;
        closeJob.Status = 5;

        CloseIncidentResponse resp = (CloseIncidentResponse)service.Execute(closeJob); 
       }
       catch (System.Web.Services.Protocols.SoapException soapEx)
       {
        
       }

    Thursday, February 18, 2010 4:29 AM
  • and here is the complete javascript code.

    var xml = "" +
    "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
    "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
    "  <soap:Header>" +
    "    <CrmAuthenticationToken xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" +
    "      <AuthenticationType xmlns=\"http://schemas.microsoft.com/crm/2007/CoreTypes\">0</AuthenticationType>" +
    "      <OrganizationName xmlns=\"http://schemas.microsoft.com/crm/2007/CoreTypes\">MicrosoftCRM</OrganizationName>" +
    "      <CallerId xmlns=\"http://schemas.microsoft.com/crm/2007/CoreTypes\">00000000-0000-0000-0000-000000000000</CallerId>" +
    "    </CrmAuthenticationToken>" +
    "  </soap:Header>" +
    "  <soap:Body>" +
    "    <Execute xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" +
    "      <Request xsi:type=\"CloseIncidentRequest\">" +
    "        <IncidentResolution xsi:type=\"incidentresolution\">" +
    "          <incidentid type=\"incident\">e16a2b61-539b-de11-94ee-0003fffeffff</incidentid>" +
    "          <subject>subject</subject>" +
    "        </IncidentResolution>" +
    "        <Status>5</Status>" +
    "      </Request>" +
    "    </Execute>" +
    "  </soap:Body>" +
    "</soap:Envelope>" +
    "";

    var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");

    xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
    xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Execute");
    xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
    xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
    xmlHttpRequest.send(xml);

    var resultXml = xmlHttpRequest.responseXML;
    alert(resultXml.xml);

    Thursday, February 18, 2010 4:36 AM
  • I think CloseIncidentRequest Message will work for your requirement.

    Here is your code :

    // Create the Request Object

     

    CloseIncidentRequest state = new CloseIncidentRequest();

     

    incidentresolution incident = new incidentresolution();

     

    Lookup oLookup = new Lookup();

     

    // EntityId is the Guid of the incident whose state is being changed

    oLookup.Value=

    new Guid("AD618DB2-F0DB-4A6A-8C4B-2F2213EAA38E");

    oLookup.type=

    EntityName.incident.ToString() ;

    incident.incidentid = oLookup ;

    incident.statuscode =

    new Status();

    incident.statuscode.Value= 5;

     

    // Set the Request Object's Properties

    state.Status = -1;

    state.IncidentResolution = incident;

     

     

    // Execute the Request

     

    CloseIncidentResponse stateSet = (CloseIncidentResponse)service.Execute(state);




    Javascript Code:  Change the organisation Name & Guid.

    var xml = "" +
    "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
    "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
    "  <soap:Header>" +
    "    <CrmAuthenticationToken xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" +
    "      <AuthenticationType xmlns=\"http://schemas.microsoft.com/crm/2007/CoreTypes\">0</AuthenticationType>" +
    "      <OrganizationName xmlns=\"http://schemas.microsoft.com/crm/2007/CoreTypes\">e4685-dep</OrganizationName>" +
    "      <CallerId xmlns=\"http://schemas.microsoft.com/crm/2007/CoreTypes\">00000000-0000-0000-0000-000000000000</CallerId>" +
    "    </CrmAuthenticationToken>" +
    "  </soap:Header>" +
    "  <soap:Body>" +
    "    <Execute xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" +
    "      <Request xsi:type=\"CloseIncidentRequest\">" +
    "        <IncidentResolution xsi:type=\"incidentresolution\">" +
    "          <incidentid type=\"incident\">ad618db2-f0db-4a6a-8c4b-2f2213eaa38e</incidentid>" +
    "          <statuscode>5</statuscode>" +
    "        </IncidentResolution>" +
    "        <Status>-1</Status>" +
    "      </Request>" +
    "    </Execute>" +
    "  </soap:Body>" +
    "</soap:Envelope>" +
    "";

    var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");

    xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
    xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Execute");
    xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
    xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
    xmlHttpRequest.send(xml);

    var resultXml = xmlHttpRequest.responseXML;
    alert(resultXml.xml);





    Mark as answer if it helps.


    Dare to promise
    • Proposed as answer by D-Virdi Thursday, February 18, 2010 5:10 AM
    Thursday, February 18, 2010 5:09 AM
  • Thanks for the code it worked well

    thanks

    Divya

    Thursday, February 18, 2010 5:13 AM
  • Please MARK as Answer if it helps... :-)
    Dare to promise
    Thursday, February 18, 2010 5:25 AM
  • Thanks deepak it worked....
    Thursday, February 18, 2010 5:37 AM