Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

I got this question about how to be able to put more advanced condition on a UI Action.

In this case specific we want to have a UI Action that will only show on incidents if there isn't any active childs incidents connected to it.

It will be pretty straight forward and use it as a simple example on how to use this for more complex situations you will get yourself into 😃

first we need to create the Script Include. If you don't know exactly how your code to to validate if your function should return true of false, play around with it in Script - background or fix script. By that way you can easy and fast test the code to make sure it will return the right values.

I have chosen to call my Script Include for condUtil, so it will say something about what it is and I can add more functions in it later that are connected to conditions.

Don't forget to at least write a few lines about what you expect the function to get as input and what it is suppose to return

Here is what the Script Include looks like:

find_real_file.png

As you can see here I created a function called "checkIncidentChilds" which takes in one parameter and this uses this to see if that sys_id has any active childs connected.

And returns true or false depending on there is any active childs.

Now I can use this on the condition field on an UI Action like this:

find_real_file.png

since it will return true if the incident doesn't have any active childs, the button will then be visible, otherwise it will return false and the button will not be seen.

By doing this you can easy create reusable conditions which can do complex checks and just return true or false.

I hope this will get your imagine going and make some magic happen.

8 Comments