hullow to all,
i'm trying to call an action using soap request. but i get an internal server error.
can anybody suggest why is this happening. i'm posting the snapshot of code and action.
*This post is locked for comments
hullow to all,
i'm trying to call an action using soap request. but i get an internal server error.
can anybody suggest why is this happening. i'm posting the snapshot of code and action.
*This post is locked for comments
yes Aman, you are right, actually i guess we can only pass entity reference and can't pass an entity through an action and the code i was trying to execute had and required an entity as i had to perform a change on one of it's attributes but i was casting an entity reference to an entity that's why invalid cast exception occured. so later i changed the code and cast it to entity reference and then retrieved it's attributes in a entity using entity reference's id,columns and logical name. and it worked.
thanks a lot for your guidance and support.
looking forward for further association over the community platform.
Hi,
You are trying to cast EntityRefrence into Entity. Can you please post your code here ?
Thanks
what does this error mean, i don't understand.
There is a much easier way to call actions from javasript
var organizationUrl = Xrm.Page.context.getClientUrl();
var data = {
"Assign": true,
"RemoveFromQueue": true,
"TargetItemObjectTypeCode": "112"
};
var query = "queues(" + queueid + ")/Microsoft.Dynamics.CRM.new_GetNextCaseFromQueue";
var req = new XMLHttpRequest();
req.open("POST", organizationUrl + "/api/data/v8.0/" + query, true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.onreadystatechange = function () {
if (this.readyState == 4) {
req.onreadystatechange = null;
if (this.status == 200) {
var caseId = JSON.parse(this.response).ItemId;
// do stuff
} else {
var error = JSON.parse(this.response).error;
alert(error.message);
}
}
};
req.send(window.JSON.stringify(data));
Hi,
After looking your screenshots ,SOAP Request is missing Target KeyValuePair.
Please find below code for execute action using JS.
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>" + EntityGuid + "</a:Id>";
requestXML += " <a:LogicalName>" + EntityName + "</a:LogicalName>";
requestXML += " <a:Name i:nil=\"true\" />";
requestXML += " </b:value>";
requestXML += " </a:KeyValuePairOfstringanyType>";
requestXML += " </a:Parameters>";
requestXML += " <a:RequestId i:nil=\"true\" />";
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);
if (req.status == 200) {
var response = req.responseXML.xml;
}
Hope it'll help you.
Thanks
Aman Kothari
André Arnaud de Cal... 291,391 Super User 2024 Season 2
Martin Dráb 230,445 Most Valuable Professional
nmaenpaa 101,156