Dynamics CRM Javascript · Javascript

{Dynamics CRM 365} Client Side Form event pipeline

You can define up to 50 event handlers for each event. Each event handler is executed in the order that it is displayed in the Event Handlers section in the Events tab of the Form Properties dialog box.

Use the execution context getDepth method to know the sequence that an event handler is being executed in relative to other event handlers.

getDepth – Returns a value that indicates the order in which this handler is executed.

I have added below code on Quote Details entity form Onchange event of Product field.

function onproductchange(executionContext){
var formContext = executionContext.getFormContext();
var product= formContext.getAttribute('productid').getValue();
if(product != null)
var productid = product[0].id;
Xrm.WebApi.retrieveRecord("product",productid, "?$select=_defaultuomid_value").then(
function success(result) {
var setunit = new Array();
setunit[0] = new Object();
setunit[0].id = result._defaultuomid_value;
setunit[0].name =result["_defaultuomid_value@OData.Community.Display.V1.FormattedValue"];
setunit[0].entityType = result["_defaultuomid_value@Microsoft.Dynamics.CRM.lookuplogicalname"];
}, function (error) { console.log(error.message); // handle error conditions }

As I had only one event handler added on Quote Details entity form, I get Depth value 1.

getDepth Client API is really helpful when we have many event handlers on form and need to check the execution order of any event handler.

Hope this helps!

One thought on “{Dynamics CRM 365} Client Side Form event pipeline

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s