Hi,
So I am trying to use the webapi to clone a current record, but I am getting stuck wjen it comes to copying over the contents of the subgrid to the cloned record. Everyone works until I get to the N to N association where it tells me an array should be there rather then a string, but I have no idea what that should look like. Any help would be appreciated
var serverURL = parent.Xrm.Page.context.getClientUrl();
var commitment = {};
commitment["new_name"] = parent.Xrm.Page.getAttribute("new_name").getValue() + " Clone";
//Recipients var allRows = parent.Xrm.Page.getControl("Recipients").getGrid().getRows();
commitment["new_new_commitment_contact@odata.bind"] = "/contacts("+allRows.get(0).getData().getEntity().getEntityReference().id.replace('{',"").replace('}',"")+")";
var req = new XMLHttpRequest(); req.open("POST", serverURL + "/api/data/v8.0/new_commitments", true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("MSCRMCallerID", (parent.Xrm.Page.getAttribute("ownerid").getValue()[0].id.replace('{',"").replace('}',"")));
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 /* complete */ )
{
req.onreadystatechange = null; if (this.status == 204)
{
}
else { var error = JSON.parse(this.response).error; alert(error.message); } } };
req.send(JSON.stringify(commitment));
*This post is locked for comments