Onchange Client script behavior on Variable Editor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2024 07:58 AM
Hi All,
I have written Onchange catalog client script to Hide/Show variable based on choice selection. But its not working on Variable Editor section . Can somebody please help me on this
I have marked "Applies on Requested Items" and "Applies on Catalog Tasks" to true, still no luck
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2024 08:28 AM
hi @ukti
When working with the Variable Editor in RITM or SCTASK, you should use g_sc_form instead of g_form. The g_form object is not available in all contexts of the Variable Editor.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
if (newValue == 'medical_device') {
g_sc_form.clearValue('medical_device_request_type');
g_sc_form.setDisplay('medical_device_request_type', true);
g_sc_form.setDisplay('exisiting_device', false);
} else if (newValue == 'addendum_contract') {
g_sc_form.showFieldMsg('request_type_sub_category', 'Any changes that is added to an existing contract to modify, clarify, or extend certain terms or add new terms', 'info');
g_sc_form.clearValue('previous_ritm');
} else {
g_sc_form.setDisplay('capital_budget', false);
g_sc_form.setDisplay('cost_center', false);
g_sc_form.setDisplay('medical_device_request_type', false);
g_sc_form.setDisplay('new_device_details', false);
}
}
If setDisplay() doesn't work, you can try using setVisible() instead to control whether the variable is shown or hidden.
i hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.
thank you
rajesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2024 11:14 AM
You need to make absolutely certain that you are using the exact variable names and values. Alert on newValue and/or inside the if, else if, and else blocks to confirm the choice values 'medical_device' and 'addendum_contract' are exactly correct. In your screenshot you appear to be testing the else block. It appears the first two variables are not displayed - or did you just not include those in the screenshot, or are they shown but labelled drastically different than what the name suggests? If the issue is only the last two variables in this block, then make sure the names you are using in the script are exactly (space and case-sensitive) the same as the variable names.
Also make sure that you do not have any other Catalog Client Scripts or Catalog UI Policies that are affecting these variables.