StartWorkflowDynamically = function (entityName, entityId, workFlowProcessID) {
entityName = "";
// var entityId = "3286F4FC-C435-E011-A258-00155D006B3F";
//var workFlowProcessID = "791b1070-adf3-49a5-a7ef-68836da0e806";
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\">" +
Xrm.Page.context.getAuthenticationHeader() +
"<soap:Body>" +
"<Request xsi:type=\"ExecuteWFProcessRequest\" " +
"xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" +
"<ProcessId>" +
workFlowProcessID +
"</ProcessId>" +
"<EntityMoniker>" +
"<Id xmlns=\"http://schemas.microsoft.com/crm/2007/CoreTypes\">" +
entityId +
"</Id>" +
"<Name xmlns=\"http://schemas.microsoft.com/crm/2007/CoreTypes\">" +
entityName +
"</Name>" +
"</EntityMoniker>" +
"</Request>" +
"</soap:Body>" +
"</soap:Envelope>" +
"";
try {
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);
}
catch (f) {
entityName = "";
// var entityId = "3286F4FC-C435-E011-A258-00155D006B3F";
//var workFlowProcessID = "791b1070-adf3-49a5-a7ef-68836da0e806";
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\">" +
Xrm.Page.context.getAuthenticationHeader() +
"<soap:Body>" +
"<Request xsi:type=\"ExecuteWFProcessRequest\" " +
"xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" +
"<ProcessId>" +
workFlowProcessID +
"</ProcessId>" +
"<EntityMoniker>" +
"<Id xmlns=\"http://schemas.microsoft.com/crm/2007/CoreTypes\">" +
entityId +
"</Id>" +
"<Name xmlns=\"http://schemas.microsoft.com/crm/2007/CoreTypes\">" +
entityName +
"</Name>" +
"</EntityMoniker>" +
"</Request>" +
"</soap:Body>" +
"</soap:Envelope>" +
"";
try {
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);
}
catch (f) {
}
var resultXml = xmlHttpRequest.responseXML;
//alert(resultXml.text);
return resultXml.xml;
} // Start Workflow//
var resultXml = xmlHttpRequest.responseXML;
//alert(resultXml.text);
return resultXml.xml;
} // Start Workflow//
// Executed using CrmService.asmx
function StartWorkflow(entityName, entityId, workFlowProcessID) {
entityName = "";
//var entityId = "3286F4FC-C435-E011-A258-00155D006B3F";
//var workflowProcessId = "791b1070-adf3-49a5-a7ef-68836da0e806";//"8d14d034-5bb8-4a49-af9b-a08777cffaaa";
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\">" +
Xrm.Page.context.getAuthenticationHeader() +
"<soap:Body>" +
"<Execute xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" +
"<Request xsi:type=\"ExecuteWorkflowRequest\">" +
"<EntityId>" + entityId + "</EntityId>" +
"<WorkflowId>" + workflowProcessId + "</WorkflowId>" +
"</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);
function StartWorkflow(entityName, entityId, workFlowProcessID) {
entityName = "";
//var entityId = "3286F4FC-C435-E011-A258-00155D006B3F";
//var workflowProcessId = "791b1070-adf3-49a5-a7ef-68836da0e806";//"8d14d034-5bb8-4a49-af9b-a08777cffaaa";
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\">" +
Xrm.Page.context.getAuthenticationHeader() +
"<soap:Body>" +
"<Execute xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" +
"<Request xsi:type=\"ExecuteWorkflowRequest\">" +
"<EntityId>" + entityId + "</EntityId>" +
"<WorkflowId>" + workflowProcessId + "</WorkflowId>" +
"</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);
}
// Excuted using IOrganizationService (WCF)
function StartWorkflowDynamic(entityID,workflowID) {
//var entityID = Xrm.Page.data.entity.getId();
var currentEntity = "";
var url = Xrm.Page.context.getServerUrl();
var entityId = entityID;
var workflowId = workflowID;
var OrgServicePath = "/XRMServices/2011/Organization.svc/web";
url = url + OrgServicePath;
var request;
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:ExecuteWorkflowRequest\" 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>EntityId</c:key>" +
"<c:value i:type=\"d:guid\" xmlns:d=\"http://schemas.microsoft.com/2003/10/Serialization/\">" + entityId + "</c:value>" +
"</a:KeyValuePairOfstringanyType>" +
"<a:KeyValuePairOfstringanyType>" +
"<c:key>WorkflowId</c:key>" +
"<c:value i:type=\"d:guid\" xmlns:d=\"http://schemas.microsoft.com/2003/10/Serialization/\">" + workflowId + "</c:value>" +
"</a:KeyValuePairOfstringanyType>" +
"</a:Parameters>" +
"<a:RequestId i:nil=\"true\" />" +
"<a:RequestName>ExecuteWorkflow</a:RequestName>" +
"</request>" +
"</Execute>" +
"</s:Body>" +
"</s:Envelope>";
//var entityID = Xrm.Page.data.entity.getId();
var currentEntity = "";
var url = Xrm.Page.context.getServerUrl();
var entityId = entityID;
var workflowId = workflowID;
var OrgServicePath = "/XRMServices/2011/Organization.svc/web";
url = url + OrgServicePath;
var request;
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:ExecuteWorkflowRequest\" 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>EntityId</c:key>" +
"<c:value i:type=\"d:guid\" xmlns:d=\"http://schemas.microsoft.com/2003/10/Serialization/\">" + entityId + "</c:value>" +
"</a:KeyValuePairOfstringanyType>" +
"<a:KeyValuePairOfstringanyType>" +
"<c:key>WorkflowId</c:key>" +
"<c:value i:type=\"d:guid\" xmlns:d=\"http://schemas.microsoft.com/2003/10/Serialization/\">" + workflowId + "</c:value>" +
"</a:KeyValuePairOfstringanyType>" +
"</a:Parameters>" +
"<a:RequestId i:nil=\"true\" />" +
"<a:RequestName>ExecuteWorkflow</a:RequestName>" +
"</request>" +
"</Execute>" +
"</s:Body>" +
"</s:Envelope>";
var req = new XMLHttpRequest();
req.open("POST", url, true)
// Responses will return XML. It isn't possible to return JSON.
req.setRequestHeader("Accept", "application/xml, text/xml, */*");
req.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
req.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute");
//req.onreadystatechange = function () { assignResponse(req); };
req.send(request);
req.open("POST", url, true)
// Responses will return XML. It isn't possible to return JSON.
req.setRequestHeader("Accept", "application/xml, text/xml, */*");
req.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
req.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute");
//req.onreadystatechange = function () { assignResponse(req); };
req.send(request);
}
function startworkfloe() {
var entityID = Xrm.Page.data.entity.getId();
var workflowID = "7f120af8-69fa-44bc-80a7-2ae1a33cbbe5";
var odataresult;
function startworkfloe() {
var entityID = Xrm.Page.data.entity.getId();
var workflowID = "7f120af8-69fa-44bc-80a7-2ae1a33cbbe5";
var odataresult;
if (odataresultname == "workflowusing Javascript") {
var workflowID = workflowID;
}
StartWorkflowDynamic(entityID, workflowID);
}
var workflowID = workflowID;
}
StartWorkflowDynamic(entityID, workflowID);
}
No comments:
Post a Comment