Script question

DeIvory Gordon
Tera Guru

Hello,  I am new to scripting and I need to add a line of script to the script on the second screen shot below.  I need to add a script so that n the request below on the User "Workflow field", when the user selects "Pantone LIVE Dependent Standard Access", “AVD_App_X-Rite-IQC-PLV” populates under the "Please provide the user with the following AD group" field.  If you can help, please explain it simply.  Thanks!

 

DeIvoryGordon_0-1738426635136.png

DeIvoryGordon_1-1738427852993.png

 

3 ACCEPTED SOLUTIONS

Voona Rohila
Kilo Patron
Kilo Patron

Hi @DeIvory Gordon 

After Line 14, add another else if condition for checking.

sample code:

else if(newValueString == 'Pantone LIVE Dependent Standard Access')
{
g_form.setValue('please_provide_the_user_with_the_following_ad_group','AVD_App_X-Rite-IQC-PLV'); //modify field name accordingly.
g_form.setReadonly('please_provide_the_user_with_the_following_ad_group',true);//modify field name accordingly.
}

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

View solution in original post

Ankur Bawiskar
Tera Patron
Tera Patron

@DeIvory Gordon 

the "User Workflow" variable is reference so please use sysId to compare and not name during comparison

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

Jim Coyne
Kilo Patron

First of all, take a look at this post:

TNT: Screenshots Help, but Code is Better

 

Secondly, I know SN will "help" by automatically creating the variable name based on the label, but "please_provide_the_user_with_the_following_ad_group" is a crazy name.  There would be a lot of people with different views here, but it could be shortened to "ad_group".

 

What kind of variable is the "User Workflow"?  Is it a Lookup Select Box or a Select Box?  The "value" of that variable may not be the label that you see.  Could be a sys_id (Lookup Select Box) or some code/string (Select Box).

View solution in original post

5 REPLIES 5

Voona Rohila
Kilo Patron
Kilo Patron

Hi @DeIvory Gordon 

After Line 14, add another else if condition for checking.

sample code:

else if(newValueString == 'Pantone LIVE Dependent Standard Access')
{
g_form.setValue('please_provide_the_user_with_the_following_ad_group','AVD_App_X-Rite-IQC-PLV'); //modify field name accordingly.
g_form.setReadonly('please_provide_the_user_with_the_following_ad_group',true);//modify field name accordingly.
}

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

Hello, Thank you for your reply, this is how the script looks after I entered the else if condition you provided (see screen shots)  However, on the User "Workflow field", when the user selects "Pantone LIVE Dependent Standard Access", “AVD_App_X-Rite-IQC-PLV” still does not populate under the "Please provide the user with the following AD group" field:

DeIvoryGordon_0-1738464846659.png

DeIvoryGordon_1-1738464915362.png

 

 

Thank you for explaining this so simply, it worked!

Ankur Bawiskar
Tera Patron
Tera Patron

@DeIvory Gordon 

the "User Workflow" variable is reference so please use sysId to compare and not name during comparison

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader