Form Event Handler Execution Context Reference
The execution context is an optional parameter that can be passed to a JScript library function through an event handler. This option is presented in the handler properties dialog when you specify the name of the function. This option is set for a <Handler> (FormXml) element using the passExecutionContext attribute.
The following table lists the execution context methods.
| Method | Description |
|---|---|
|
Returns the Xrm.Page.context object. |
|
|
Returns a value that indicates the order in which this handler is executed. |
|
|
Returns an object with methods to manage the Save event. |
|
|
Returns a reference to the object that the event occurred on. |
|
|
Retrieves a variable set using setSharedVariable. |
|
|
Sets the value of a variable to be used by a handler after the current handler completes. |
getContext
getDepth
Returns a value that indicates the order in which this handler is executed.
ExecutionObj.getDepth()
- Return Value
- Type: Number The order begins with 0.
getEventArgs
Returns an object with methods to manage the Save event.
Note |
|---|
| This method returns null for any event other than the Save event. |
ExecutionObj.getEventArgs()
- Return Value
- Type: Object For more information, see Save Event Arguments Reference.
getEventSource
Returns a reference to the object that the event occurred on.
ExecutionObj.getEventSource()
- Return Value
-
Type: Object
This method returns the object from the Xrm.Page object model that is the source of the event, not an HTML DOM object. For example, in an OnChange event, this method returns the Xrm.Page.data.entity attribute object that represents the changed attribute.Example: When the SDK.UISamples.bindSectionVisibilityToBooleanAttribute function is configured to the OnChange event of the Boolean attribute and the event handler is configured to pass the name of a form section, the visibility of the section is bound to the value of the Boolean attribute.
/* This generic function can be used to bind the visibility of any section to the value of a boolean attribute. It requires the following: 1. It must only be added to the OnChange event of a Boolean attribute 2. When configuring the event handler, you must pass the execution context as the first parameter. 3. When configuring the event handler, you must specify the name of the section in the comma separated list of parameters that will be passed to the function. For example, if you want to hide the section with the name "marketing information", you must enter the following information in the field: "marketing information" (using quotation marks). Note: The section name value can be edited in the application. If this value is changed after event handler has been configured the function will not work. */ SDK.UISamples.bindSectionVisibilityToBooleanAttribute = function (eContext, sectionName) { Xrm.Page.ui.tabs.forEach(function (tab, index) { tab.sections.forEach(function (section, index) { if (section.getName() == sectionName) { section.setVisible(eContext.getEventSource().getValue()) } }); }); };
getSharedVariable
Retrieves a variable set using setSharedVariable.
ExecutionObj.getSharedVariable(key)
- Arguments
- String: The name of the variable.
- Return Value
- Type: Object The specific type depends on what the value object is.
setSharedVariable
Microsoft Dynamics CRM 2011
Send comments about this topic to Microsoft.
© 2013 Microsoft Corporation. All rights reserved.
Note