USD – Switch Agent Scripts

I recently received a great question about agents scripts and I love answering Unified Service Desk questions! This time the question was about a requirement to switch agents scripts. Here is my answer.

The question I received is shown below;

So essentially this person has multiple agent scripts and as tabs are selected wants to automatically show the agent script that relates to the selected tab. This seemed quite a logical thing to want to achieve, when looking at my case I’d like to see the agent script that relates to answers associated to the case. But if I also had an opportunity open then the agent script should automatically switch to be focused on opportunity when the user clicks on the opportunity tab.

I did manage to achieve this effect, although there were a couple of minor things to be aware of. In the rest of this post I will explain how I answered this problem;

The simple steps involved are;

  1. Create a SelectedAppChanged event, if you don’t already have one.
  2. Create some Agent Script GotoTask actions.
  3. Associate the GotoTask actions with SelectedAppChanged event.

Step One – Create a SelectedAppChanged event

You will have a hosted control of type “PanelLayout”. Mine is called “Main Layout”. Other common names might be “Custom Panel Layout” etc.

Find your panel layout hosted control and open its associated events view. You need to check you have an event called “SelectedAppChanged”. If you do great. If you don’t simple click “ADD NEW EVENT” and create one.

Step Two – Create some Agent Script GotoTask actions

Next you will need an action to load each of the agent scripts you want to enable this automatic switching feature on. You can see below that I decided to apply this logic to four of my tabs. Account, Contact, Case and Opportunity.

You will no doubt have a different naming convention to me, so may need to take that into account.

My hosted control for accounts is called “Account”, cases is called “Cases” etc. (Fairly typical.)

My agent script for accounts is called “Account – Agent Script”, cases is called “Case – Agent Script” etc.

Knowing this let’s look at one of my actions in a little more detail. I will use my action for the account hosted control as an example, I hope you can see how these might vary for each tab.

Field Details
Name Agent Scripting – Goto Task (Account, When Selected)
Hosted Control Agent Scripting
Action GotoTask
Data Account – Agent Script

Obviously the name you have here will probably be different to mine. But this is simply the name of the script I want to show when my Account tab is selected.

Condition “[[Selection]+]”==”Account” && “[[Agent Scripting.msdyusd_name]+]”!=”Account – Agent Script”

This condition (importantly) checks two things.

  • Firstly we use the “Selection” parameter to know if the tab currently selected is the Account tab.
  • Secondly I check that the current agent script isn’t already the one the GotoTask is trying to load. This second check is actually really important! As without this I found that Unified Service Desk was actually crashing as my tabs loaded!

Step Three – Associate the GotoTask actions with SelectedAppChanged event

The final step was to simply add my actions to the SelectedAppChanges event. You can see below that I added all four of my actions.

Hopefully I have managed to answer the question and maybe given you an idea on how to enhance your agent scripts.

3 thoughts on “USD – Switch Agent Scripts

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 )

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