How to create a multiple conditions in UI Action

RamSagar
Tera Guru

Hi,

Could you please help in creating a multiple condition check in UI Action condition.

1) i want to check if state == "open" UI action should be visible to only ITIL

2) if state == "work in progress" ui action should be visible to "change_admin" roled users.

thanks in advance.

9 REPLIES 9

Brad Tilton
ServiceNow Employee
ServiceNow Employee

How about:



((current.state == 9 || current.state == 11) && gs.hasRole('change_manager')) || (current.state != 11 && current.state != 9 && gs.hasRole('itil'))


Hi,



There cannot be multiple "States" applied at the same time.



Try with this:


((current.state == 9 || current.state == 11) && gs.hasRole('change_manager')) || ((current.state != 11 || current.state != 9) && gs.hasRole('itil'))


Brad Tilton
ServiceNow Employee
ServiceNow Employee

When you say it's not working do you mean that the condition is evaluated to true or false? Also, the state field is an integer so your numbers shouldn't be in quotes in this instance. Also, with your states whenever the state is 11 or 9, the first set of state conditions will be true as well.


Hi Ramu,



Simplify and break it down to find the failure in your condition. Start with just the roles comparisons, then add one condition at a time back in to see where your mistake lies.



Then comes the fun.




-Brian



Rahul Jain11
Kilo Guru

Your condition should be like:



(gs.hasRole('itil') && !current.isNewRecord() && (current.state != '5' || current.state != '4' || current.state != '3')) || (gs.hasRole('change_manager') && (current.state == '11' || current.state == '9'))