I'm trying to call a custom action through Javascript. Here's the code
var host = window.opener.Xrm.Page.context.getClientUrl().toString() + "/api/data/v8.2/";
var url = host + "new_customAction";
var data = {
Record: {
"@odata.type": "Microsoft.Dynamics.CRM.new_profile",
"@new_profile.id": recordId,
},
Date: date
,
Comment: comment
};
console.log(window.JSON.stringify(data));
var request = new XMLHttpRequest();
request.open("POST", url);
request.setRequestHeader("Accept", "application/json");
request.setRequestHeader("Content-Type", "application/json; charset=utf-8");
request.setRequestHeader("OData-MaxVersion", "4.0");
request.setRequestHeader("OData-Version", "4.0");
request.send(window.JSON.stringify(data));
Here's the parameters passed printed by console.log :
{"Record":{"@odata.type":"Microsoft.Dynamics.CRM.new_profile","@new_profile.id":"67F01BEE-98B2-E711-9403-06A5B6453DB2"},"Date":"2018-01-18T00:00:00Z","Comment":"test"}
When I execute this code, I get "message: Required field 'Record' is missing".
Anyone know what I'm doing wrong? Record is of type EntityReference in my custom action.
*This post is locked for comments
I have the same question (0)