Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

UI Action Condition Syntax Question

ndejoya
Tera Contributor

Hello everyone! Just wanted to ask a quick question that I hope is pretty simple, I think my syntax is just a little off. Relatively new to developing in ServiceNow and in the process of creating a UI Action with some conditions for a button to show up. I think I'm missing something small here but can't seem to get it to show. The condition for the button to show is that: 

 

1. It needs to be in status 123, or status ABC, or status XYZ

AND 

2. The user has to have either role 1 or role 2 

 

I can't seem to get the syntax correct to show for these conditions in the UI Action, hopefully someone can help. Thank you for the time

1 ACCEPTED SOLUTION

mihirlimje867
Tera Guru

Hello @ndejoya ,

For the roles you can add in the condition field: gs.hasRole('role 1, role 2')  or you can simply add in the requires role tab.

For the Status you can added in condition like: current.getValue('status') == '123' || current.getValue('status') == 'ABC' || current.getValue('status') == 'XYZ'


Thank you.


View solution in original post

2 REPLIES 2

JenniferRah
Mega Sage
Mega Sage

It will depend on the actual field name for status for whatever form you are using, but here's something to get you started:

(current.status== '123' || current.status == 'ABC' || current.status == 'XYZ') && (gs.hasRole('role1') || gs.hasRole('role2'))

mihirlimje867
Tera Guru

Hello @ndejoya ,

For the roles you can add in the condition field: gs.hasRole('role 1, role 2')  or you can simply add in the requires role tab.

For the Status you can added in condition like: current.getValue('status') == '123' || current.getValue('status') == 'ABC' || current.getValue('status') == 'XYZ'


Thank you.