Home > Uncategorized > Inactivate and Resolve case using Javascript

Inactivate and Resolve case using Javascript


 
Today i got some intersting requirement from my client ,it goes as below
 
They asked to set case as resolved when particular value from the picklist selected in the case form.so i was trying to trigger Actions-> Resolve case .with javascript just i’m able to expand the Action menu not able to trigger Resolve case click.Finaly i tried to use Ajax webservice call to set case as resoleved .That worked the code as below
 

function ResolveCase() {

// Activate / deactivate contact

var xml = "<?sXml version="1.0" encoding="utf-8"?>";

xml +=

"<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd="http://www.w3.org/2001/XMLSchema">&quot;;

xml += GenerateAuthenticationHeader().toString();

xml += "<soap:Body><Execute xmlns=’http://schemas.microsoft.com/crm/2007/WebServices’><Request xsi:type=’CloseIncidentRequest’>";

xml +=

"<IncidentResolution>";

xml +=

"<statuscode>5</statuscode><subject>Case resolved</subject><description>case resolved</description><incidentid type="incident">" + crmForm.ObjectId + "</incidentid>";

xml +=

"</IncidentResolution> <Status>5</Status>";

xml +=

"</Request></Execute></soap:Body></soap:Envelope>";

var oXmlHttp;

var arrProgIds = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP", "MSXML2.XMLHTTP.3.0"];

for (var iCount = 0; iCount < arrProgIds.length; iCount++) {

try {

oXmlHttp =

new ActiveXObject(arrProgIds[iCount]);

break;

}

catch (e) { }

}

oXmlHttp.open(

"POST", "/mscrmservices/2007/crmservice.asmx", false);

oXmlHttp.setRequestHeader(

"Content-Type", "text/xml; charset=utf-8");

oXmlHttp.setRequestHeader(

"SOAPAction", "http://schemas.microsoft.com/crm/2007/WebServices/Execute&quot;);

oXmlHttp.onreadystatechange =

function() {

if (oXmlHttp.readyState == 4) {

WSResultHandler(oXmlHttp.responseXML);

}

};

oXmlHttp.send(xml);

}

function WSResultHandler(resp) {

debugger;

window.opener.location = window.opener.location;

crmForm.detachCloseAlert();

window.close();

}

Happy coing

Advertisements
Categories: Uncategorized
  1. February 5, 2014 at 8:33 pm

    I have been surfing on-line greater than 3 hours as of late, but I
    by no means discovered any fascinating article like yours.
    It’s lovely value sufficient for me. In my view, if
    all website owners and bloggers made just right content as you probably did, the web can
    be much more useful than ever before.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: