- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2020 02:21 AM
Hi Community,
I'm writing a client script to check whether the assignment group starts with 'IT' or not I tried many proposed solutions in the script but it is not working can anyone please suggest the correct way to check the condition.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2020 02:28 AM
Hi Shiva,
you can write onChange client script on assignment group field
Sample script below
Use proper field name for assignment_group
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
var groupName = g_form.getDisplayBox('assignment_group').value;
groupName = groupName.toString();
if(groupName.startsWith('IT')){
alert('starts with IT');
}
else{
alert('doesn't start with IT');
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2020 02:28 AM
Hi Shiva,
you can write onChange client script on assignment group field
Sample script below
Use proper field name for assignment_group
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
var groupName = g_form.getDisplayBox('assignment_group').value;
groupName = groupName.toString();
if(groupName.startsWith('IT')){
alert('starts with IT');
}
else{
alert('doesn't start with IT');
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2020 02:39 AM
Hi,
Try below onChange client script.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
var groupVal= g_form.getReference('assignment_group').name;
if(groupVal.startsWith('IT')){
alert('Group name starts with IT');
}
else{
alert('Group name doesn't start with IT');
}
}
Thanks,
Dhananjay.