- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2023 04:46 AM
I have these variables on my catalog item:
application_service is on cmdb_ci_service table.
support_group is on sys_user_group table
When application_service changes I want support_group to change automatically.
This is my catalog client script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var supportGroup = '';
var cmdbCiService = new GlideRecord('cmdb_ci_service');
cmdbCiService.addQuery('sys_id', newValue);
cmdbCiService.query();
g_form.addInfoMessage("OUSIDE: "+newValue);
if (cmdbCiService.next()) {
supportGroup = cmdbCiService.getValue('support_group');
g_form.addInfoMessage("Support: " + supportGroup);
}
g_form.setValue("variables.support_group", supportGroup);
}
I am able to fetch the sys_id correctly but not able to set the value. How can I do this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2023 05:00 AM
@vidhya_mouli This can be done without scripting. Open the "Support group" variable and go to "Auto populate" section.
In dependent question, select Application service and "Sys ID" in dot walk path field.
If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2023 05:11 AM
Hi @vidhya_mouli ,
You don't need any scripting for this. Use the Auto populate option which is on your support group variable.
Select the dependent question as Application service and on Dot walk path select the Support group.
Refer below screen.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2023 04:52 AM
@vidhya_mouli Ideally you should never make a GlideRecord query from the client script as it doesn't work on the Service portal. You can use a combination of a GlideAjax in client script and a script include.
Since you are testing this script on the backend and managed to get the sys_id. You can apply the following fix to set value on the support_group field.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var supportGroup = '';
var cmdbCiService = new GlideRecord('cmdb_ci_service');
cmdbCiService.addQuery('sys_id', newValue);
cmdbCiService.query();
g_form.addInfoMessage("OUSIDE: "+newValue);
if (cmdbCiService.next()) {
supportGroup = cmdbCiService.getValue('support_group');
g_form.addInfoMessage("Support: " + supportGroup);
}
g_form.setValue("support_group", supportGroup);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2023 04:53 AM
I tried this. But it did not work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2023 05:00 AM
@vidhya_mouli This can be done without scripting. Open the "Support group" variable and go to "Auto populate" section.
In dependent question, select Application service and "Sys ID" in dot walk path field.
If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2023 05:11 AM
Hi @vidhya_mouli ,
You don't need any scripting for this. Use the Auto populate option which is on your support group variable.
Select the dependent question as Application service and on Dot walk path select the Support group.
Refer below screen.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar