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.

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

🙂

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: