- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2021 04:05 AM
We would like to set a default value for a Select Box on a form based upon a selection of another Select Box. In our scenario, the user would pick "Tax Changes & Commodity Code" from this select box.
We would want the following select box, below, to populate "Tax" as the default value in this Select Box (aka put it at the top). So basically, the dropdown, where the down arrow is, would be populated with "Tax" but the user still could pick from any of the other options. We would do the same if someone picked "Add/Activate/Deactivate Accounts or BU" in the list above, it would default to "Accounting", and so on. We cannot figure our with either g_form.setValue or g_form.addOptions or something else how to make this happen.
Any assistance would be greatly appreciated.
Thank you,
Colleen
Solved! Go to Solution.
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2021 04:24 AM
Hi Colleen,
You'll need to create an onChange Catalog Client Script when the first variable changes. Your script will start out something like this.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if(newValue == 'Tax Changes...'){//replace with the Value of your choice
g_form.setValue('variable_name', 'Tax');//replace with your variable name and the choice Value
}
}
Once you have it working for the first example, copy the three lines of the if block and modify for every newValue choice. Be sure to use the exact choice values and not the labels.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2021 04:24 AM
Hi Colleen,
You'll need to create an onChange Catalog Client Script when the first variable changes. Your script will start out something like this.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if(newValue == 'Tax Changes...'){//replace with the Value of your choice
g_form.setValue('variable_name', 'Tax');//replace with your variable name and the choice Value
}
}
Once you have it working for the first example, copy the three lines of the if block and modify for every newValue choice. Be sure to use the exact choice values and not the labels.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2021 06:12 AM
Thank you Brad!!! We spent about a couple hours yesterday going back and forth to get this to work. And it worked!!! Thank you!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2021 06:25 AM
You are welcome!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2021 11:24 AM
Trying this code for my State and Status of Request fields. It's not working. Also note that this is not a Catalog Client Script. It's just a Client Script on the form in the UI Platform.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var state = g_form.getValue('state');
var status = g_form.getValue('u_status_of_request');
if (newValue=='3'){
g_form.setValue('status','closed');