Page 1 of 1

Change field to Required If Condition met

Posted: 2022-01-20 18:40
by dharbitindy
Hello,

Does anyone know what the code is and where it should be placed to change a non-required field to required if a condition is met? For instance, If another field's value called Eff Percentage is less than let's say 95.0, then the Notes field would then become a required field in the Detail View?

Thanks much,
David

Re: Change field to Required If Condition met

Posted: 2022-01-22 14:57
by pbottcher
Hi,

you can add some code to the hooks/TABLENAME-dv.js file (create it if it does not exist)

Add something like

Code: Select all

if (CONDITION) {
    $j('#FIELDID').attr('required', true)}
}
This would make your field mandatory.

!! This will not alert you directly with a Popup message like AppGini does. This would need some extra code.

Re: Change field to Required If Condition met

Posted: 2022-01-23 04:08
by dharbitindy
As always, thank you sir! Very much appreciated.

I did change the .attr to .prop and the AppGini Popup message also showed up.

Thanks again,
David