Users with the Location of China should not be able to request Adobe Creative / Pro
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2024 06:26 AM
Hi,
If user location is "Shanghai, China" as below image mentioned.
Then user should not be able to add "Adobe Creative / Pro" OR "Adobe Creative / Pro" software will not shown in that list ("List the Software Needed" variable is a List Collector variable) .
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2024 08:01 AM
Hi @Omkarbh1997 ,
In the above request form you can directly access the value of the location field in your Client Script.
Create a onload client script-
function onLoad() {
// Get the value of the location field, replate user_location with location field on request form
var userLocation = g_form.getValue('user_location');
// If the user is in Shanghai, China, filter out Adobe Creative/Pro
if (userLocation.includes('Shanghai, China')) {
filterAdobeSoftware();
}
}
function filterAdobeSoftware() {
// Replace 'software_needed' with List Collector variable name
var listCollector = g_form.getControl('software_needed');
var itemsToRemove = ['Adobe Creative/Pro']; // Items to remove from the list
for (var i = 0; i < listCollector.options.length; i++) {
var option = listCollector.options[i];
if (itemsToRemove.includes(option.text)) {
listCollector.remove(i);
i--;
}
}
}
You can also use a property to store the location, rather then hard coding it(ServiceNow best Practices). For that you may need to modify the scripts, and extend the logic as per your need.
If my response has resolved your query, please consider giving it a thumbs up and marking it as the correct answer!
Thanks & Regards,
Sanjay Kumar