Home
> JScript, PowerApps > Tip | Model Driven Apps | Client API | setSharedVariable and getSharedVariable
Tip | Model Driven Apps | Client API | setSharedVariable and getSharedVariable
As we know Client-side scripting using JavaScript is one of the ways to apply custom business process logic for displaying data on a form in a model-driven app, In this article lets understand how to pass variables between event handlers (i.e., Different jScript functions registered as event handlers).
Lets understand this by first understanding the Form event pipeline.
Form event pipeline:
- We 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.
- We can use the setSharedVariable and getSharedVariable methods to pass a common variable between event handlers (functions).
setSharedVariable:
- Sets the value of a variable to be used by a handler after the current handler completes.
- Syntax : ExecutionContextObj.setSharedVariable(key, value);
- Ex : ExecutionContextObj.setSharedVariable(“sharedAccountName“, formContext.getAttribute(“name”).getValue());
getSharedVariable:
- Retrieves a variable set using the setSharedVariable method.
- Syntax: var sharedVariable = ExecutionContextObj.getSharedVariable(key);
- Xrm.Navigation.openAlertDialog({ text: ExecutionContextObj.getSharedVariable(“sharedAccountName“) });
🙂
Categories: JScript, PowerApps
getSharedVariable, setSharedVariable
Comments (0)
Trackbacks (0)
Leave a comment
Trackback