Catalog Client Script to set Values of Dependent Fields

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 11:01 AM
I have a catalog item with a variable set that includes 'business unit' as a reference from the OOB 'business_unit' table, 'business group' and 'business function' both of which are lookup select boxes to a custom table with reference qualifiers dependent on business unit.
In my catalog item, these fields are hidden by UI Policy on all except the catalog task. I have a client script that I want to set the values of these three fields (only on this one catalog item).
My onLoad script is as follows:
function onLoad() {
g_form.setValue('business_unit', 'eacc8ef3db5414d08b6cf77c299619e2', 'Global Operations');
g_form.setValue('business_group', 'Global Operations');
g_form.setValue('business_function', 'b64abb101bf1dc102804ba215b4bcba2', 'Procurement & Corp Purchasing');
}
It sets the business unit and business group fields correctly, but will not set the business function. I have tried setting the last line to
g_form.setValue('business_function', 'Procurement & Corp Purchasing');
with no luck. Thinking the ampersand might be the issue, I changed the value of the choice to 'Procurement Corp Purchasing'. Didn't work. The select box options on business function ARE correct on the form when it loads with the business unit and group loaded, so the right options are available, it just isn't selecting it.
Can anyone give me some other things to try?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 01:01 PM
Hi @tsutherland ,
Can you please try following code.
function onLoad() {
g_form.setValue('business_unit', 'eacc8ef3db5414d08b6cf77c299619e2';
g_form.setValue('business_group', 'sys_id of group'); // add sys_id of group
g_form.setValue('business_function', 'b64abb101bf1dc102804ba215b4bcba2');
}
Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2023 09:32 AM
Tried that as well, and unfortunately it didn't work.