We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Hi Everyone, My below code is not working in the page...can someone help me with the error in the

ruthra_85
Tera Contributor
 var act = g_form.getValue('u_active');
 
    if (act == true){
        g_form.setMandatory('u_location',true);
    }
    else if(act == false){
        g_form.setMandatory('u_location',false);
    }
5 REPLIES 5

Ankur Bawiskar
Tera Patron

@ruthra_85 

are you sure the script is running in correct view?

try this

var act = g_form.getValue('u_active').toString();
 
    if (act == 'true'){
        g_form.setMandatory('u_location',true);
    }
    else if(act == 'false'){
        g_form.setMandatory('u_location',false);
    }

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader