How to debug MSCRM Action in 2015,2016
How to debug MSCRM Action?
Here I am going to explain how we can debug an Action in
Microsoft Dynamics CRM 2016.
I think everyone might aware of calling an Action using JavaScript
for both Global and Entity specific. First, we need to register the Action
message and its step using Plugin in registration tool.
Steps 1: Register your Action using plug in registration
tool.
Step 2: Click on Install Profiler in plug-in registration
tool.
Step 3: Click on “Start Profiling” option in plug-in registration
tool.
Step 4: Now call the Action using JavaScript. It will create
a Plug-in Trace log message in “Plug-in Trace Log” entity in CRM with the Action
message name.
Ex: here in my case Action message name is new_editableGridGlobalAction
How to call Action using JavaScript:
function CallGlobalAction() {
var data = {
"EntitySchemaName": entitySchemaName,
"RecordID": recordId,
"GridData": gridData,
"ConfigurationValue": configName,
}
var response = ExecuteGenericAction("idoc_EditableGridGlobalAction", data, false);
}
//Calling
generic Action calling
function ExecuteGenericAction(url, dataCollection, isSync) {
try {
var response = null;
var req = new
XMLHttpRequest();
var clientURL = Xrm.Page.context.getClientUrl();
var url = encodeURI(clientURL + "/api/data/v8.1/" + url);
req.open("POST", url, isSync);
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 response = JSON.parse(this.response);
if (response != null) {
debugger;
//admissionId = response["AdmissionID"]
}
}
else {
var error = JSON.parse(this.response).error;
alert("Error while executing query – " + error.message);
}
}
};
req.send(window.JSON.stringify(dataCollection));
return response;
} catch (e) {
ShowAlert("Error occured:" + e.message);
}
}
In CRM site, we need to configure as below screenshot.
Step 5: As I said above step 4, after calling action, it
creates a record in “plug-in trace log”. Need to open the latest record as
below screen shot.
Step 6: Open the latest record from plug in trace log
entity. Copy paste “Exception Details” field value into some notepad and save
it.
Step 7: Open the plug-in registration tool and add your
saved note pad file and your action assembly and debug it.
Comments
Post a Comment