Dynamics 365: Obtaining Execution, Form, And Grid Context
In Microsoft Dynamics 365, the execution context defines the execution context for an event that occurs on a form or grid. You can use the execution context to get the form context, and if required then use the form context to get the grid context for a grid on the form. You can use these contexts to perform custom business logic, including but not limited to, getting and setting attribute values, altering the visibility of interface elements, referencing various controls, accessing multiple forms, manipulating form navigation, and interacting with business process flows.
The execution context is an optional parameter so you will need to pass it into your JavaScript functions before you can benefit from it. You can achieve this by opening the Event Handler Properties dialog from the Form Properties dialog, selecting a Library from a dropdown, and entering the name of a function within the selected library. Make sure that both the Enabled and Pass execution context as first parameter options are selected before clicking the OK button. When this is done, the execution context will be passed as the first parameter into the function as soon as the specified event is triggered. Therefore, it is important to consider the parameters received by your function. The execution context is automatically passed as the first parameter to all functions set using code.
This is how to retrieve the formContext object and the gridContext object after passing the execution context into your JavaScript function.
function Function(executionContext) { var formContext = executionContext.getFormContext(); var gridContext = formContext.getControl("GridName"); }
*This post is locked for comments