USD – SaveSetting

In Unified Service Desk for Microsoft Dynamics CRM 2016, I have often used User Settings to define how various parts of my application should behave for a given user. For example, I have used them is to decide which users should see the debugger.

Users settings are great for defining defaults like this but these settings could be more powerful if you could set them at runtime. And now you can!

Let me give you an example, when my application loads I have a number of global tabs that I always load by default. (Loaded in the DeskTopReady event of my global manager.) That is great but can be frustrating as I often find myself wanting to close the same tabs as soon as USD loads. But other user may always want them to open. A much better approach would be for the system to remember the last state and when USD is loaded open the “correct” tabs based on user preference.

I feel a simple example is needed ……..…

I have a tab called “CRM Home” that displays the CRM home page. Simples! Some users may want this routinely open others might not. How can I achieve this????

  1. Create an action to save a setting with a value as true.
  2. Create an action to save a setting with a value as false.
  3. In my DeskTopReady event, add the user setting as a condition.
  4. When tab is closed, call an action.
  5. When tab reopened from toolbar, call an action.

Step One – Create an action, open as true

The first action I need writes a user setting called “HomeOpen” with a value of True. Notice that my hosted control is my global manager and the action is SaveSetting.

Then in the data field I give the name I want the parameter to have and its value. So …


What this action does is write a setting to the USD configuration for the current user. At runtime! Below you can see I have run the action and it has been created under my name. Being written to the database like this means it will still be present next time I load USD. (Useful!)

Step Two – Create an action, open as false

Now I needed a second action, which was almost the same as the first. This one, however, wrote a value of False. Simple. J

Step Three – In DeskTopReady event, add the user setting as a condition.

So now let’s look at how I can use the results from these actions! Firstly, I only wanted to load the CRM home page if the setting was True. I already had an action which navigated to the CRM Home page. This was already being called in my DeskTopReady event. (Sorry, I am making an assumption that you already know how to achieve these things!)

My existing navigate action looked like this …. It simply does a navigate action to the CRM home page. (main.aspx)

All I needed to do was add the following condition to my “navigate” action.

Notice I have used “[[$Settings.HomeOpen]+]”!=”False”, there is a reason! As by looking for not equal to False I will display the tab if the setting is True or not present. (or null.)

Step Four – When tab closed, call action to save setting, open as false.

Now I wanted to change my setting to false if the user closes the tab. So that the tab would then not open the next time I load USD.

This was easy enough but you’ll first need to add an event. (If you don’t have it already.) I added a Closing event to the hosted control I use for my CRM Home page. (Called CRM Home!) This is simple, just navigate to the events on your hosted control and select new event. Then give it a name of Closing.

After I had saved my new event I added the action I’d already created.

Step Five – When tab reopened from toolbar, call action to save setting, open as true.

I have a home button on my main toolbar, having closed the tab if the user re-opened it using this home button I would want to remember they’d done this.

This part was simple enough, it just needed to add the other action I’d created to my toolbar button.

I guess you will need to adapt this example to work with whatever tab you wish to apply this logic on but hopefully you get the idea. The SaveSetting action could also be used to store all kinds of other information for specific users.

Hopefully this example will have given you several ideas. J

2 thoughts on “USD – SaveSetting

  1. Pingback: USD – The Book | Microsoft Dynamics CRM and Unified Service Desk

  2. Pingback: USD – Enhanced Debugger | Microsoft Dynamics CRM and Unified Service Desk

Leave a Reply

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

You are commenting using your 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