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.

Need Condition for UI action to appear based on the choice list users

malaisamyj
Tera Contributor

Hi All,

I have an another requirement as below,

I have a choice list field where this field is referenced to 'sys_users' table. So that we can choose more than one user as per our requirement.

Based on this choice list field i have an UI action.

Condition for the UI action is

UI action should appear to the users who are all chosen in the choice list field.

So i have tried with the below conditions its not working. Can someone help   me?

current.cl_ownerLIKEjavescript;gs.getUserID();

Thanks,

Malaisamy

1 ACCEPTED SOLUTION

snehabinani26
Tera Guru

3 Using indexOf("searchString")

Use indexOf("searchString") to return the location of the string passed into the method if the glide list field, such as a Watch list, has at least one value in it. If the field is empty, it returns undefined. To avoid returning an undefined value, do any of the following:


  • Force the field to a string, such as: watch_list.toString().indexOf("searchString")
  • Check for an empty Glide list field with a condition before using indexOf(), such as: if (watch_list.nil() || watch_list.indexOf("searchString") == -1)

See if this helps.



http://wiki.servicenow.com/index.php?title=Referencing_a_Glide_List_from_a_Script#gsc.tab=0


View solution in original post

8 REPLIES 8

snehabinani26
Tera Guru

3 Using indexOf("searchString")

Use indexOf("searchString") to return the location of the string passed into the method if the glide list field, such as a Watch list, has at least one value in it. If the field is empty, it returns undefined. To avoid returning an undefined value, do any of the following:


  • Force the field to a string, such as: watch_list.toString().indexOf("searchString")
  • Check for an empty Glide list field with a condition before using indexOf(), such as: if (watch_list.nil() || watch_list.indexOf("searchString") == -1)

See if this helps.



http://wiki.servicenow.com/index.php?title=Referencing_a_Glide_List_from_a_Script#gsc.tab=0


Hi Shishir,



Thanks for the quick reply.



My scenario is different.



I want condition to display an UI action button to the users who are all selected in the choice list field.



for Example:



There is a field called cl_owner which is a choice list field and referenced to users.



if the field is chosen to have three users and only these three users should be able to see the button.


I want condition for the above criteria.



Thanks,



Malaisamy