Save, Resolve the Case and Refresh the Form



//Save the Form
Xrm.Page.data.entity.save();

//Build Request - Here the Status would be "Resolved" and Status Reason is 5 i.e. Problem Solved Pass Entity ID
var request = "<s:Envelope xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'>" +
" <s:Body>" +
" <Execute xmlns='http://schemas.microsoft.com/xrm/2011/Contracts/Services' xmlns:i='http://www.w3.org/2001/XMLSchema-instance'>" +
" <request i:type='b:CloseIncidentRequest' xmlns:a='http://schemas.microsoft.com/xrm/2011/Contracts' xmlns:b='http://schemas.microsoft.com/crm/2011/Contracts'>" +
" <a:Parameters xmlns:c='http://schemas.datacontract.org/2004/07/System.Collections.Generic'>" +
" <a:KeyValuePairOfstringanyType>" +
" <c:key>IncidentResolution</c:key>" +
" <c:value i:type='a:Entity'>" +
" <a:Attributes>" +
" <a:KeyValuePairOfstringanyType>" +
" <c:key>incidentid</c:key>" +
" <c:value i:type='a:EntityReference'>" +
" <a:Id>" + entityid + "</a:Id>" +
" <a:LogicalName>incident</a:LogicalName>" +
" <a:Name i:nil='true' />" +
" </c:value>" +
" </a:KeyValuePairOfstringanyType>" +
" </a:Attributes>" +
" <a:EntityState i:nil='true' />" +
" <a:FormattedValues />" +
" <a:Id>00000000-0000-0000-0000-000000000000</a:Id>" +
" <a:LogicalName>incidentresolution</a:LogicalName>" +
" <a:RelatedEntities />" +
" </c:value>" +
" </a:KeyValuePairOfstringanyType>" +
" <a:KeyValuePairOfstringanyType>" +
" <c:key>Status</c:key>" +
" <c:value i:type='a:OptionSetValue'>" +
" <a:Value>" + 5 + "</a:Value>" +
" </c:value>" +
" </a:KeyValuePairOfstringanyType>" +
" </a:Parameters>" +
" <a:RequestId i:nil='true' />" +
" <a:RequestName>CloseIncident</a:RequestName>" +
" </request>" +
" </Execute>" +
" </s:Body>" +
"</s:Envelope>";
var xmlHttpRequest = new XMLHttpRequest();
xmlHttpRequest.open("POST", Xrm.Page.context.prependOrgName("/XRMServices/2011/Organization.svc/web"), false)
xmlHttpRequest.setRequestHeader("Accept", "application/xml, text/xml, */*");
xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHttpRequest.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute");
xmlHttpRequest.send(request);

//Refresh the Data
Xrm.Page.data.refresh();

Advertisements

About Kishore Dhanekula

MS Dynamics CRM and .NET Architect
This entry was posted in CRM, Java Script, Ms Dynamics CRM 2013, MS Dynamics CRM 2015. Bookmark the permalink.

1 Response to Save, Resolve the Case and Refresh the Form

  1. 罗勇 says:

    I have test your method, it does not work.

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 )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s