using UI Policy check field Mandatory, but sometimes it seems didn' t work

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2019 11:44 AM
hi experts,
I have a requirement , when both of the following conditions are met, it need to check some fields Mandatory. All of those fields Mandatory check is before clicking update button.
1. states=closed;
2.when u_wi_update = 1-7, checking related fields
i want to use UI Policy to achieve it.
, but it always have some check errors.
for example, when i choose "1:xxxxxx", it check 4 fields Mandatory, it hasn't error , but if i change to "3:xxxxxx" , it just check 1 fields.
i don't know why . could anyone give some advise? thanks in advance.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2019 01:20 PM
Hi,
You appear to be using multiple UI Policies to act against the same fields. This is not recommended practice and appears to be the cause of your issue - particularly if these all have the same order. This is because the policies will try to apply, and if 'Reverse when false' is not set to true multiple of them will attempt to act.
In this case I would recommend using a single UI Policy, with a condition such as:
'u_wi_update','IN','1,2,3,4,5,6,7' && 'state','=','closed'
Then, use UI policy actions for the fields consistent across these - u_code and u_employee_number.
Lastly, use an 'execute when true' script to manage the remaining fields, such as:
var wi = g_form.getValue('u_wi_update'); // Get the current value
if(wi == '1' || wi == '2'){ // First policy condition, make sure the value is what your values are
g_form.setMandatory('u_amount_remittance', true);
g_form.setMandatory('u_date', true);
}
else if(wi == '3'){ // Second policy condition, make sure the value is what your values are
g_form.setMandatory('short_description', true);
g_form.setMandatory('u_date', true);
}
else if(wi == '4' || wi == '5' || wi == '6'){ // Third, make sure the value is what your values are
// UI Policy actions currently manage u_code and u_employee, but you can add more here
}
else{
// If you want something else to happen, such as setting a mandatory field to not be mandatory
}
// Use reverse is true with this code, or otherwise manage
// setting mandatory to false in 'execute when false'
As noted, this works best when the 'reverse when false' button is ticked. Otherwise you can manage the functionality in script form.
Hope this helps clarify, please let me know if this is helpful or if you want further help.
Kind Regards,
Astrid

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2019 06:44 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2019 09:44 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2019 11:14 PM
you don't need script for this. simple ui policy condition will fulfill this requirement.
may i know the exact issue ? also try to give higher order on your UI policy