- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I have a simple on change catalog client script as below, here entity_name is reference type variable, changes_entity_appointment_ownership is select box variable and appointments is MRVS and except for entity_name no other field gets cleared. I know appointments is MRVS and that can be the reason for it but How to resolve this for select box type variable?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @khareakshay ,
Your g_form.clearValue() syntax is correct. The issue is most likely with the Select Box variable configuration rather than clearValue() itself.
For a Select Box variable, first check whether the variable allows an empty value.
Recommended approach:
1. Open the changes_entity_appointment_ownership variable.
2. Make sure "Include none" is enabled.
3. Make sure there is no Default value configured.
4. Check that another Catalog Client Script or Catalog UI Policy is not setting the value again.
Then this should be sufficient:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_form.clearValue('entity_name');
g_form.clearValue('changes_entity_appointment_ownership');
}
The important point is that clearValue() clears the selected value; it does not remove the choices from the Select Box.
If the Select Box does not have an empty/None option, the control may continue to display a selectable value instead of remaining blank.
Do not use clearOptions() just to reset the selected value, because clearOptions() removes the available choices themselves.
If the choices are being generated dynamically and you intentionally use clearOptions(), add the blank option back before adding the valid choices:
g_form.clearOptions('changes_entity_appointment_ownership');
g_form.addOption('changes_entity_appointment_ownership', '', '-- None --');
Then add the required choices.
Regarding appointments:
Since appointments is an MRVS, treat it separately. If the requirement is to remove all MRVS rows, you can reset the MRVS value using an empty JSON array:
g_form.setValue('appointments', JSON.stringify([]));
So I would test the Select Box first with "Include none" enabled. If it still does not clear, check the browser console and verify whether another Catalog Client Script/UI Policy is repopulating that variable immediately after this script executes.
Hope this helps!
If this response helped, please mark it as Helpful.
If it resolves your issue, please Accept it as Solution.
Kind Regards,
Abhishek Pal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @Abhishek Pal ,
My script works when I change the value of variable to something different but it did not work if I remove the selected value of variable. FYI the variable on which this client script works is of type reference.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago