Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Form Event Handler Execution Context Reference

[Applies to: Microsoft Dynamics CRM 2011]

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

getContext

Returns the Xrm.Page.context object.

getDepth

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

getEventArgs

Returns an object with methods to manage the Save event.

getEventSource

Returns a reference to the object that the event occurred on.

getSharedVariable

Retrieves a variable set using setSharedVariable.

setSharedVariable

Sets the value of a variable to be used by a handler after the current handler completes.

getContext

Returns the Xrm.Page.context object.

ExecutionObj.getContext()
Return Value
Type: Object

Methods

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.

Methods

getEventArgs

Returns an object with methods to manage the Save event.

noteNote
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.

Methods

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()) }
  });
 });
};

Methods

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.

Methods

setSharedVariable

Sets the value of a variable to be used by a handler after the current handler completes.

ExecutionObj.setSharedVariable(key, value)
Arguments
String: The name of the variable

Object: The value to set.

Methods

Microsoft Dynamics CRM 2011
Send comments about this topic to Microsoft.
© 2013 Microsoft Corporation. All rights reserved.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.