UI Action Condition: 'is one of' or 'is not one of' possible?

andy_dufresne
Tera Expert

HI All,

I have a cancel button that I want to show only when a user has role 'Change_coordinator' and the state of change is not one of 14, 12, or 3

So My UI condition is:

gs.hasRole("change_coordinator") &&   current.state NOT IN '14','12','3')

ServiceNow doesnt like it, it reports the following error:

Do you know how I can get condition to show: 'is one of' or 'is not one of'?

find_real_file.png

Thanks in advance for your help!

1 ACCEPTED SOLUTION

Tanaji Patil
Tera Guru

Hi, This is not possible but you can do same (IN) with "gs.hasRole('change_coordinator' && (current.state == '14' || current.state == '12' || current.state == '3')". And NOT IN with "gs.hasRole('change_coordinator' && current.state == '14' && current.state == '12' && current.state == '3'".


Thanks, Tanaji Patil


View solution in original post

9 REPLIES 9

Tanaji Patil
Tera Guru

Hi, This is not possible but you can do same (IN) with "gs.hasRole('change_coordinator' && (current.state == '14' || current.state == '12' || current.state == '3')". And NOT IN with "gs.hasRole('change_coordinator' && current.state == '14' && current.state == '12' && current.state == '3'".


Thanks, Tanaji Patil


Try the later condition i.e. NOT IN provided.


Community Alums
Not applicable

Hi,
I know this is an old thread but here's an alternative that seems to work . . .

gs.hasRole("change_coordinator") &&   (current.state != ('14'||'12'||'3')

> (current.state != ('14'||'12'||'3')

Doesn't do what you think. ('14'||'12'||'3') is evaluated to '14', then is compared to current.state. It would only work for '14', not '12', nor '3'.

john_s_valentin
Giga Contributor

This pattern scales well to long lists, especially useful if you have limited space in your Condition:

['14', '12', '3'].indexOf(current.state.toString()) == -1

Alternatively, the 'is one of' pattern:

['14', '12', '3'].indexOf(current.state.toString()) > -1