In Unified Service Desk I often only want to run actions when a particular tab is open. The problem is users are unpredictable things and they may have closed the tab without me knowing or maybe they never opened it. I could just run all the actions regardless and ignore any errors. But I don’t like doing that and it isn’t an efficient way of designing a solution. So, what so we do?

The solution is really simple and one I use on a regular basis, but I don’t think I have mentioned it in my blog before. So here goes ….

Imagine you want to run some JavaScript on the phone call tab but you don’t know if the user has that open. What would the action need to look like to not cause an error?

Imagine I have a RunXrmCommand action like the one below. Whatever code I want to run on my phone call tab will fail if the tab isn’t open.

Stopping the error is easy! Simply add a condition that uses “IsAppLoaded”.

CRMGlobalManager.IsAppLoaded("<<Your tab name>>")===true

Now the action will only run if the phonecall tab is loaded!

Hopefully this is a simple tip but one that is useful to USD fans! Enjoy.