Hi. I have a custom action on the case (incident) entity which I use to send an email. The Web API URL I'm POSTing to is:
The case exists and I can see it in a browser at:
https://portals8.crm4.dynamics.com/api/data/v8.1/incidents(581DAD43-175B-E611-9402-0003FF7D3CF6)
If I go to the metadata (https://portals8.crm4.dynamics.com/api/data/v8.1/$metadata), I can NOT see my custom action listed as an <Action> tag. The action is activated.
By JS function to call the Action is as follows:
// Hook this function up to the "Email Care Plan" button using the Ribbon Workbench. SDK.CaseForm.emailCarePlan = function() { console.log("mdl: mdl_SDK.CaseForm.js: emailCarePlan()."); // Refuse to send the email if the daignosis isn't done yet. var knowledgeArticle = Xrm.Page.getAttribute("mdl_knowledgearticle").getValue(); if (knowledgeArticle === undefined || knowledgeArticle == null) { alert("This case doesn't yet have a care plan in the portal."); return; } var orgUrl = Xrm.Page.context.getClientUrl(); var caseId = Xrm.Page.data.entity.getId(); caseId = caseId.replace("{", ""); caseId = caseId.replace("}", ""); // The "mdl_EmailCarePlan" part of this must match the unique name of the custom action and // that action must be on cases (incidents). var url = orgUrl + "/api/data/v8.1/incidents(" + caseId + ")/Microsoft.Dynamics.CRM.mdl_EmailCarePlan"; console.log("Hitting " + url); var data = { "dummyParam": "dummyValue" }; var req = new XMLHttpRequest(); req.open("POST", url, 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) { // 4: DONE req.onreadystatechange = null; if (this.status == 200 || this.status == 204) { alert("Thank you. The care plan link will be sent shortly."); } else if (this.status >= 400) { var error = JSON.parse(this.response).error; alert("Please report this error to support: Email Care Plan button on Case" + " form. " + error.message); } } } req.send(window.JSON.stringify(data)); };
The custom action looks like this.
I've put the dummy param and value in as a work around. CRM Online seemed to require at least one param here.