- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 02:13 PM
Hi Community,
Need help, I have a variables set, one variable 'Office Location' is reference to cmn_location table and another variable 'ttt' is 'select box' type in which I have added question choices.
The requirement is when the 'Office Location' is china > I have to show option in 'xxx' as > aaa, bbb, Other (default = aaa).
Appriciate any help!
I tried this script but no luck.
Regards,
Rafmine.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2022 06:48 AM
I tried to simplify your script. Try below script.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
g_form.clearOptions('office_location');
return;
}
alert('loopin');
g_form.clearOptions('office_location');
g_form.getReference('office_location', callback);
function callback(gr) {
if (gr.name == 'France') {
g_form.addOption('laptop_keyboard_layout', 'Azerty FR', 'Azerty FR');
g_form.addOption('laptop_keyboard_layout', 'Qwerty US', 'Qwerty US');
} else if (gr.name == 'United Kingdom') {
g_form.addOption('laptop_keyboard_layout', 'Qwerty UK', 'Qwerty UK');
} else {
g_form.addOption('laptop_keyboard_layout', 'Azerty BE', 'Azerty BE');
g_form.addOption('laptop_keyboard_layout', 'Qwerty US', 'Qwerty US');
}
g_form.addOption('laptop_keyboard_layout', 'Other', 'Other');
}
alert('loopout');
}
Hopefully, this will work for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 02:32 PM
Hello ,
I think in the alert you have to put the text in quotes like alert('loopin');
This might stop the execution of the script at this line .
so may be becoz of this its not executing the further script .
Place it in quotes and try
Hope this helps
Please mark my answer correct if this helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 02:39 PM
Hi Mohith,
Thanks for answering my post, I tried with test quotes but no luck, not sure where i'm going wrong. can you help me?
Regards,
Rafmine

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 02:39 PM
Hi Rafmine,
What Mohith said will solve your problem I think. Still if it doesnt here is a good example of making values dependent using client scipt.
Creating Dependent Variables in Service Catalog? Here are two ways how it can be done.
Mark Correct or helpful if it helps.
***Mark Correct or Helpful if it helps.***
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 03:11 PM
Hi,
You are using g_form.getDisplayValue('office_location'); which seems to be a problem to me.
Try using below script.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_form.getReference('office_location', callback);
}
function callback(gr) {
if (gr.name == 'United Kingdom'){
// Your logic here.
}
}