- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2022 07:34 AM
Hello all,
I'm trying to get this one working but without any luck. I want to change the choice options in the Subtype field based on what the requestor will choose in the Type field. I have created a catalog client script for this.
It should be as follow: Indoor - Climbing stair,Pushup
Outdoor - Cycling,Running
Thank you for any help!
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var typeChoice = g_form.getValue('type');
if (typeChoice == 'indoor') {
g_form.removeOption('subtype', 'running');
g_form.removeOption('subtype', 'cycling');
g_form.addOption('subtype', 'pushup');
g_form.addOption('subtype', 'climbing_stairs');
} else if (typeChoice == 'outdoor') {
g_form.removeOption('subtype', 'pushup');
g_form.removeOption('subtype', 'climbing_stairs');
g_form.addOption('subtype', 'running');
g_form.addOption('subtype', 'cycling');
}
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2022 08:01 AM
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var typeChoice = g_form.getValue('type');
if (typeChoice == 'indoor') {
g_form.removeOption('subtype', 'running');
g_form.removeOption('subtype', 'cycling');
g_form.addOption('subtype', 'pushup');
g_form.addOption('subtype', 'CHOICE_VALUE', 'CHOICE
_LABEL', );
g_form.addOption('subtype', 'CHOICE_VALUE', 'CHOICE
_LABEL', );
} else if (typeChoice == 'outdoor') {
g_form.removeOption('subtype', 'pushup');
g_form.removeOption('subtype', 'climbing_stairs');
g_form.addOption('subtype', 'CHOICE_VALUE', 'CHOICE
_LABEL', );
g_form.addOption('subtype', 'CHOICE_VALUE', 'CHOICE
_LABEL', );
}
}
AFTER CHECKING IT TYR THIS SCRIPT i gave above
Hope this helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2022 07:37 AM
Hello
try this
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var typeChoice = g_form.getValue('type');
if (typeChoice == 'indoor') {
g_form.clearOptions('subtype');
g_form.addOption('subtype', 'pushup');
g_form.addOption('subtype', 'climbing_stairs');
} else if (typeChoice == 'outdoor') {
g_form.clearOptions('subtype');
g_form.addOption('subtype', 'running');
g_form.addOption('subtype', 'cycling');
}
}
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-24-2022 07:54 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2022 08:01 AM
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var typeChoice = g_form.getValue('type');
if (typeChoice == 'indoor') {
g_form.removeOption('subtype', 'running');
g_form.removeOption('subtype', 'cycling');
g_form.addOption('subtype', 'pushup');
g_form.addOption('subtype', 'CHOICE_VALUE', 'CHOICE
_LABEL', );
g_form.addOption('subtype', 'CHOICE_VALUE', 'CHOICE
_LABEL', );
} else if (typeChoice == 'outdoor') {
g_form.removeOption('subtype', 'pushup');
g_form.removeOption('subtype', 'climbing_stairs');
g_form.addOption('subtype', 'CHOICE_VALUE', 'CHOICE
_LABEL', );
g_form.addOption('subtype', 'CHOICE_VALUE', 'CHOICE
_LABEL', );
}
}
AFTER CHECKING IT TYR THIS SCRIPT i gave above
Hope this helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2022 08:23 AM
Hello Mohith,
your solution with choice value and choice label works. Thank you very much:)