- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2022 01:47 AM
Hi All,
We have multi choice variable called (service ) in that we have multiple choices. if the choice contains 'SP', we need to set a other variable single line text value as ''123'', if the choice contains 'ORACLE,' we need to set a other variable single line text value as ''456'',.
Please suggest,
Thanks All.
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2022 04:01 AM
Hi,
update as this
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var service = g_form.getValue("vic_ServiceTier");
if(service.indexOf('SQL') > -1){
g_form.setValue("vic_PortNumber", "1433");
}
else if(service.indexOf("Oracle") > -1){
g_form.setValue("vic_PortNumber", "1521");
}
}
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
04-26-2022 02:04 AM
You wanna write onchange client script on the service field
your code should look something like:
var service = g_form.getValue("service");
if(service == 'SP'){
g_form.setValue("field_name_1", "123");
}
if(sevice == "ORACLE"){
g_form.setValue("field_name_2", "456");
}
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2022 03:05 AM
Hi Kumar,
Thanks for reply.
I have implemented above script but its not working. in this script we mentioned if(service == 'SQL')
But its not equal it should be contains.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var service = g_form.getValue("vic_ServiceTier");
if(service == 'SQL'){
g_form.setValue("vic_PortNumber", "1433");
}
if(sevice == "Oracle"){
g_form.setValue("vic_PortNumber", "1521");
}
}
Please suggest.
Thanks,

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2022 05:14 AM
If is multiselect then you have to use indexOf, sorry didn't notice it before:
But what about the scenarios, where you have both SQL and Oracle selected,
Make sure to properly map the field names while populating values.
I think Ankur's script should help
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2022 02:18 AM
Hi,
Should be simple enough with Catalog Client Script onChange of Multi choice variable
what have you started and where are you stuck?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader