If the short description contains INFRA keyword in the beginning then category should add a new choice "infra" and set it to the same by using on change clientscript
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2020 02:12 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2020 02:23 AM
Hi,
As per your question it seems you require onChange client script
sample below
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var shortDesc = g_form.getValue('short_description');
if(shortDesc.startsWith('INFRA')){
g_form.addOption('choice_field','infra' ,'Infra');
}
else{
g_form.removeOption('choice_field','infra');
}
}
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
12-05-2020 09:40 PM
Hope you are doing good.
Did my reply answer your question?
If so, please mark appropriate response as correct & helpful so that the question will appear as resolved for others who may have a similar question in the future.
Thanks!
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
11-30-2020 10:06 AM
Hi Vinod,
Minor update to the script to set the value as well.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var shortDesc = g_form.getValue('short_description');
if(shortDesc.startsWith('INFRA')){
g_form.addOption('choice_field','infra' ,'Infra');
g_form.setValue('choice_field','infra');
}
else{
g_form.removeOption('choice_field','infra');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2022 01:11 AM
The query was "
If the short description contains INFRA"
but resolution given was "