- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2025 08:40 AM
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!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2025 10:32 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2025 07:35 PM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2025 07:38 PM
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).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2025 10:32 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2025 06:57 PM
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:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2025 06:42 AM
Thank you for explaining this so simply, it worked!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2025 07:35 PM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader