Export (0) Print
Expand All

Execution context (client-side reference)

Applies To: Microsoft Dynamics CRM 2013, Microsoft Dynamics CRM Online

The execution context is an optional parameter that can be passed to a JavaScript 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.

Execution context is automatically passed to functions set using the Xrm.Page.data.entity.addOnSave and Xrm.Page.data.entityAttribute.addOnChange, and Xrm.Page.uiControl.addPreSearch methods.

getContext
Method that returns the Client-side context (client-side reference) object.

getDepth
Method that returns a value that indicates the order in which this handler is executed.

getEventArgs
Method that returns an object with methods to manage the Save event.

getEventSource
Method that returns a reference to the object that the event occurred on.

Shared Variables
Shared variables allow sharing of a variable with other handlers for the same event. You use the setSharedVariable and getSharedVariable methods to work with shared variables.

Method that returns the Client-side context (client-side reference) object


          ExecutionContextObj.getContext()
Return Value
Type: Object

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

Return Value
Type: Number

The order begins with 0.

Method that returns an object with methods to manage the Save event.

noteNote
This method returns null for any event other than the Save event.


          ExecutionContextObj.getEventArgs()
Return Value
Type: Object

For more information, see Save event arguments (client-side reference).

Method that returns a reference to the object that the event occurred on.


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

Shared variables allow sharing of a variable with other handlers for the same event. You use the setSharedVariable and getSharedVariable methods to pass variables between functions.

setSharedVariable

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


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

Object: The value to set.

getSharedVariable

Retrieves a variable set using setSharedVariable.


            ExecutionContextObj.getSharedVariable(key)
Arguments
String: The name of the variable.

Return Value
Type: Object

The specific type depends on what the value object is.

Microsoft Dynamics CRM 2013 and Microsoft Dynamics CRM Online
Send comments about this topic to Microsoft.
© 2014 Microsoft Corporation. All rights reserved.
Show:
© 2014 Microsoft