Advertisement
Guest User

Untitled

a guest
Feb 28th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 KB | None | 0 0
  1. function RunWorkflow() {
  2. var _return = window.confirm('Are you want to execute workflow.');
  3. if (_return) {
  4. var url = Xrm.Page.context.getClientUrl();
  5. var entityId = Xrm.Page.data.entity.getId();
  6. var workflowId = '8b386814-6a3d-4b3c-93a4-e6aaa1bb0b92';
  7. var OrgServicePath = "/XRMServices/2011/Organization.svc/web";
  8. url = url + OrgServicePath;
  9. var request;
  10. request = "<s:Envelope xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'>" +
  11. "<s:Body>" +
  12. "<Execute xmlns='http://schemas.microsoft.com/xrm/2011/Contracts/Services' xmlns:i='http://www.w3.org/2001/XMLSchema-instance'>" +
  13. "<request i:type='b:ExecuteWorkflowRequest' xmlns:a='http://schemas.microsoft.com/xrm/2011/Contracts' xmlns:b='http://schemas.microsoft.com/crm/2011/Contracts'>" +
  14. "<a:Parameters xmlns:c='http://schemas.datacontract.org/2004/07/System.Collections.Generic'>" +
  15. "<a:KeyValuePairOfstringanyType>" +
  16. "<c:key>EntityId</c:key>" +
  17. "<c:value i:type='d:guid' xmlns:d='http://schemas.microsoft.com/2003/10/Serialization/'>" + entityId + "</c:value>" +
  18. "</a:KeyValuePairOfstringanyType>" +
  19. "<a:KeyValuePairOfstringanyType>" +
  20. "<c:key>WorkflowId</c:key>" +
  21. "<c:value i:type='d:guid' xmlns:d='http://schemas.microsoft.com/2003/10/Serialization/'>" + workflowId + "</c:value>" +
  22. "</a:KeyValuePairOfstringanyType>" +
  23. "<a:KeyValuePairOfstringanyType>" +
  24. "<b:key>testinput</b:key>" +
  25. "<b:value i:type='c:string' xmlns:c='http://www.w3.org/2001/XMLSchema'>Some Text</b:value>" +
  26. "</a:KeyValuePairOfstringanyType>" +
  27. "</a:Parameters>" +
  28. "<a:RequestId i:nil='true' />" +
  29. "<a:RequestName>ExecuteWorkflow</a:RequestName>" +
  30. "</request>" +
  31. "</Execute>" +
  32. "</s:Body>" +
  33. "</s:Envelope>";
  34.  
  35. var req = new XMLHttpRequest();
  36. req.open("POST", url, false)
  37. req.setRequestHeader("Accept", "application/xml, text/xml, */*");
  38. req.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
  39. req.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute");
  40. req.send(request);
  41. var response = JSON.parse(req.responseText);
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement