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

zhihong
Tera Contributor

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 fieldsfind_real_file.png

i want to use UI Policy to achieve it.

find_real_file.pngfind_real_file.png

find_real_file.pngfind_real_file.pngfind_real_file.pngfind_real_file.png

, 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.

find_real_file.pngfind_real_file.png

i don't know why . could anyone give some advise? thanks in advance.

19 REPLIES 19

Astrid Sapphir1
Giga Expert

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

hi Astrid,

Thank you so much for reply in detail, now I have modified in one UI Policy, as following:

find_real_file.png

However, I have a question ,

>Lastly, use an 'execute when true' script to manage the remaining fields

do I need to write a script?  write where?

hi Astrid,

I have tried it , but still have check errors as before.

what went wrong? Please help me .

find_real_file.pngfind_real_file.png

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