Make field mandatary based on another field changes

VSN
Tera Expert

i have 2 fields in the Program table. 1. Employee 2. Portfolio.

my requirement is for new record,  employee field is mandatory,

after saving the form if we change the value in Portfolio then the employee field is not mandatory.

2 REPLIES 2

Anand Kumar P
Giga Patron
Giga Patron

Hi @VSN ,

if you need to Onchange client script Portfolio is behavior like Onchange as well as onload -:

do the simple change in if condition remove the isLoading || 

eg.

function onChange(control, oldValue, newValue, isLoading) {
if ( newValue == '') {

if(g_form.isNewRecord()){

g_form.setMandatory('employee',true);
}else if(oldValue!=newValue){

g_form.setMandatory('employee',false);

}

Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand

 

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @VSN 

 

You an make it on load client script or UI policy.

 

May i know the reason why you dont want it to make mandatory after save, you can make it read only if all good. 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************