- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2022 12:17 PM
Hi,
I have a choice field that is hidden with one UI Policy. I need that field to show up when a date field is updated. I was able to have the choice field display with a second UI policy but it disappears after saving the form. The order between the ui policies are different. Is there a way to do a client script to hide the field and show when date field is updated?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2022 02:58 PM
One could move all mandatory and visibility controls for the Choice field into a Client Script (as UI Policies are executed after Client Script and would overwrite whatever the Client Script instructs). One could write an onChange Client Script for the Date field, something like:
function onChange (control, oldValue, newValue, isLoading, isTemplate) {
if (has_date_field_been_modified(oldValue, newValue))
show_choice_filed('<choice field name>');
else
hide_choice_filed('<choice field name>');
function has_date_field_been_modified (oldValue, newValue) {
return oldValue != newValue;
}
function hide_choice_filed (fieldName) {
g_form.setMandatory(fieldName, false);
g_form.setVisible(fieldName, false)
}
function show_choice_filed (fieldName) {
g_form.setVisible(fieldName, true)
g_form.setMandatory(fieldName, true);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2022 01:06 PM
Add a condition on your first one to show not only when the date field is updated but also when the choice field has a value selected. Then you do not need the second one.
Aoife
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2022 02:58 PM
One could move all mandatory and visibility controls for the Choice field into a Client Script (as UI Policies are executed after Client Script and would overwrite whatever the Client Script instructs). One could write an onChange Client Script for the Date field, something like:
function onChange (control, oldValue, newValue, isLoading, isTemplate) {
if (has_date_field_been_modified(oldValue, newValue))
show_choice_filed('<choice field name>');
else
hide_choice_filed('<choice field name>');
function has_date_field_been_modified (oldValue, newValue) {
return oldValue != newValue;
}
function hide_choice_filed (fieldName) {
g_form.setMandatory(fieldName, false);
g_form.setVisible(fieldName, false)
}
function show_choice_filed (fieldName) {
g_form.setVisible(fieldName, true)
g_form.setMandatory(fieldName, true);
}
}