UI Policy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2024 06:38 AM - edited 09-10-2024 06:47 AM
Please ignore this
I have a on submit client script as below
If location ='s X > it makes the additional field mandatory and adds a field message.
But, is it possible to do the reverse? It is achievable by a client script but not through a UI policy. :[This is needed because when the user tries to change the location from X the additional field which was mandated is not getting reversed.]
If location is not 'X' > to make the additional field non-mandatory and hide the field message.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2024 06:45 AM
yes it is possible using onSubmit client script, you just need to add else condition in your script as bellow:
else {
g_form.setMandatory(additionalField, false); // Replace with the actual field name you want to make mandatory/non-mandatory
g_form.hideFieldMsg(additionalField);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2024 06:52 AM - edited 09-10-2024 06:56 AM
Hi @Ramkumar Thanga,
This should absolutely be possible via a UI Policy, however, as requested, to set this via a Client Script simply leverage an 'If' statement and the g_form method of .setMandatory('field_name', boolean) as below:
if(g_form.getValue('location_field_name') == 'X'){
g_form.setMandatory('field_name', true);
}
else{
g_form.setMandatory('field_name', false);
g_form.hideFieldMsg('additional_field_name');
}
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.
Thanks, Robbie