Hi Andreas Cieslik
I make my custom work flow and add this custom work flow into crm through plug in registration tool and I add this custom work flow into work flow of crm with the help of add step and call this code on button click's event.
function CallActionFromJavaScript() {
debugger;
//var entityId = Xrm.Page.data.entity.getId();;
var entityName = "list";
var requestName = "MailChimpIntegration Test";
ExecuteActionCreateProject(/*entityId,*/ entityName, requestName);
}
function ExecuteActionCreateProject(/*EntityId,entityId,*/ entityName, requestName) {
// Creating the request XML for calling the Action
var requestXML = ""
requestXML += "<s:Envelope xmlns:s=\"schemas.xmlsoap.org/.../envelope\">";
requestXML += " <s:Body>";
requestXML += " <Execute xmlns=\"schemas.microsoft.com/.../Services\" xmlns:i=\"www.w3.org/.../XMLSchema-instance\">";
requestXML += " <request xmlns:a=\"schemas.microsoft.com/.../Contracts\">";
requestXML += " <a:Parameters xmlns:b=\"schemas.datacontract.org/.../System.Collections.Generic\">";
requestXML += " <a:KeyValuePairOfstringanyType>";
requestXML += " <b:key>Target</b:key>";
requestXML += " <b:value i:type=\"a:EntityReference\">";
//requestXML += " <a:Id>"+entityId+"</a:Id>";
//requestXML += " <a:LogicalName>"+entityName+"</a:LogicalName>";
requestXML += " <a:Name i:nil=\"true\">";
requestXML += " </a:Name></b:value>";
requestXML += " </a:KeyValuePairOfstringanyType>";
requestXML += " <a:KeyValuePairOfstringanyType>";
requestXML += " <b:key>EntityId</b:key>";
requestXML += " <b:value i:type=\"c:string\" xmlns:c=\"www.w3.org/.../XMLSchema\"></b:value>";
requestXML += " </a:KeyValuePairOfstringanyType>";
requestXML += " </a:Parameters>";
requestXML += " <a:RequestId i:nil=\"true\">";
requestXML += " </a:RequestId>";
requestXML += " <a:RequestName>"+requestName+"</a:RequestName>";
requestXML += " </request>";
requestXML += " </Execute>";
requestXML += " </s:Body>";
requestXML += "</s:Envelope>";
var req = new XMLHttpRequest();
req.open("POST", GetClientUrl(), false)
req.setRequestHeader("Accept", "application/xml, text/xml, */*");
req.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
req.setRequestHeader("SOAPAction", "schemas.microsoft.com/.../Execute");
req.send(requestXML);
//Get the Response from the CRM Execute method
//var response = req.responseXML.xml;
req.onerror = function (e) {
alert(req.statusText);
};
if (req.status === 200) {
alert(req.responseText);
}
}
function GetClientUrl() {
if (typeof Xrm.Page.context == "object") {
clientUrl = Xrm.Page.context.getClientUrl();
}
var ServicePath = "/XRMServices/2011/Organization.svc/web";
return clientUrl + ServicePath;
}
My code is not working by doing this all. When I run my code on visual studio. It is working and creating list. Where am I wrong please do let me know.
Thank you