Execute custom/system ACTION using Web API in MS CRM 2016

//Custom Action with parameters to add a notes to account record.

Action unique name: new_customaction.
Input Parameter:  Name=’Title’
var notesData = {
    "Title": "Sample Notes."
};
var query = "accounts(34C77C3E-E6F7-E511-80E5-005056981E85)/Microsoft.Dynamics.CRM.new_customaction";
var request = new XMLHttpRequest();
request.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v8.0/" + query, true);
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.onreadystatechange = function () {
    if (this.readyState == 4) {
        request.onreadystatechange = null;
        if (this.status == 200) {
            // Successful

        }
    }
};

Comments

Popular posts from this blog

Basic Plugin Code in D365 using C#

CURD (Create, Update, Retrieve and Delete) Operation in D365 using Power Shell Script

Meta Data Using WebApiRequest