- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2025 11:33 AM - edited 04-22-2025 11:35 AM
I have a Script that I need help with. I have this to load the CI Support group based on the that CI. But groups no longer want to get these for some. SO I have a value on the Group called u_no_generic_request and it's set to true for the group that don't want to get them. I am trying to have it look at that field if that is set to 'true' then don't autoload the support group but if it's 'false' then it can. This script though is saying they are all set to generic no matter what i pick. I know i have something wrong I am just not sure what. TIA
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
if (newValue == '') {
g_form.setValue('support_group', '');
return;
}
if (!g_form.getControl('support_group')) {
return;
}
var group = g_form.getReference('support_group');
if (group && group.u_no_generic_requests === false) {
g_form.setValue('support_group', newValue);
} else {
g_form.clearValue('support_group');
alert('The selected group does not accept Generic Service Requests and cannot be set as the support group.');
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2025 11:45 AM - edited 04-22-2025 12:00 PM
Hello @Wendy Peterson ,
I understand you have a variable for selecting a CI and a variable for a Support group on your Catalog Item.
Which of these two variables is this onChange Script running on?
Assuming it's an onChange of the Support group variable, the script would need to look like this:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_form.getReference('support_group', group => {
if (group && group.u_no_generic_requests === 'false') {
g_form.clearValue('support_group');
g_form.showErrorBox('support_group', 'The selected group does not accept Generic Service Requests and cannot be set as the support group.');
}
});
}
Regards,
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2025 11:45 AM - edited 04-22-2025 12:00 PM
Hello @Wendy Peterson ,
I understand you have a variable for selecting a CI and a variable for a Support group on your Catalog Item.
Which of these two variables is this onChange Script running on?
Assuming it's an onChange of the Support group variable, the script would need to look like this:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_form.getReference('support_group', group => {
if (group && group.u_no_generic_requests === 'false') {
g_form.clearValue('support_group');
g_form.showErrorBox('support_group', 'The selected group does not accept Generic Service Requests and cannot be set as the support group.');
}
});
}
Regards,
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2025 12:00 PM - edited 04-22-2025 12:01 PM
It's running on the Configuration Name Field (configuration_name) on change that goes the CI's and it's auto populating the Support Group (support_group) of the CI. But I don't want it to populate if that u_generic_service_requests is true. TIA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2025 12:11 PM
Hello @Wendy Peterson ,
Thanks for the clarification.
Please make your onChange script run on the Support group variable instead, and use the script I provided earlier (also pasting it again below).
And then please update the configuration of the Support group variable like this:
This will take care of auto-populating the Support group based on the selected CI. No scripting required for that part.
So we only need the script on the Support group variable to check if that auto-populated group has "u_no_generic_requests" set to false.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_form.getReference('support_group', group => {
if (group && group.u_no_generic_requests === 'false') {
g_form.clearValue('support_group');
g_form.showErrorBox('support_group', 'The selected group does not accept Generic Service Requests and cannot be set as the support group.');
}
});
}
Regards,
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2025 12:13 PM
This is what I originally had and this works. But It's not looking at the Support Group to see if that flag is set.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
if (newValue == '') {
g_form.setValue('support_group', '');
return;
}
if (!g_form.getControl('support_group')) {
return;
}
var ci = g_form.getReference('configuration_name', setSupportGroup);
}
function setSupportGroup(ci) {
if (ci) {
g_form.setValue('support_group', ci.support_group);
}
}
