USD – What is the Context, Global and Session

Leave a comment

In Unified Service Desk, there are several areas where data is stored that helps with the functioning of the application. If we open USD and go to the Debugger, we can see, depending on where we are in the application, different areas such as Context, Global and Session store different replacement parameters. These are useful for different reasons such as:

  • Creating URLs through substituting a string
  • Specifying strings for entity searches
  • Inputs for hosted controls
  • CTI

Let’s go through what each of these replacement parameter types are.

Opening the debugger and navigating to Data Parameters, you might see something like below:

Context

Context refers to what is currently in the session context. Expanding context parameters, we see:

Now let’s open a case, which starts a new Session:

Refresh the context, and you will see the parameters being displayed come from the Case that is currently being displayed:

Now let’s say the user clicks on a contact instead of a case, which also starts a new session. Let’s see what the $Context looks like in this case. It shows information relating to the customer record:

You can also add new parameters to the context through the CopyToContext action, as well as change the value of existing context parameters. Context is useful if you have common parameters across different entities, e.g. firstname might appear in case as well as customer, so you can reference it in your code as [[$Context.firstname]]. It is also useful if you want to copy other replacement parameters into the $Context. For example, $Session will be removed when a session is finished – if you copy $Session variables to the $Context, you would be able to use those later such as if you want to retrieve information from a previous session.

In hosted controls code, the NotifyContextChange event runs when a change occurs in the context, so the developer can determine what to do when there parameters change (e.g. display a different record).

Global

Whether you are in a session or not, you will see Global parameters. These look like below:

This shows how USD is configured if you were to navigate to Options in Dynamics 365:

Session

The $Session stores information specific to the session, such as the Id, number of sessions, etc:

If you close all sessions, you will have a count of 0 and IsGlobal = true.

THANKS FOR READING. BEFORE YOU LEAVE, I NEED YOUR HELP.
 

I AM SPENDING MORE TIME THESE DAYS CREATING YOUTUBE VIDEOS TO HELP PEOPLE LEARN THE MICROSOFT POWER PLATFORM.

IF YOU WOULD LIKE TO SEE HOW I BUILD APPS, OR FIND SOMETHING USEFUL READING MY BLOG, I WOULD REALLY APPRECIATE YOU SUBSCRIBING TO MY YOUTUBE CHANNEL.

THANK YOU, AND LET'S KEEP LEARNING TOGETHER.

CARL

https://www.youtube.com/carldesouza

 

ABOUT CARL DE SOUZA

Carl de Souza is a developer and architect focusing on Microsoft Dynamics 365, Power BI, Azure, and AI.

carldesouza.comLinkedIn Twitter | YouTube

 

Leave a Reply

Your email address will not be published. Required fields are marked *