In Change Table, Field should be mandatory and visible only to Change Manager in New State.

SajithM
Tera Contributor

In Change Table, Field should be mandatory and visible only to Change Manager in New State.

6 REPLIES 6

I used the script below and it does not work. Please assist
function onLoad() {
   
    var isChangeManager = g_user.hasRoleExactly('change_manager');
    var currentState = g_form.getValue('state');
    var fieldName = 'u_risk_assessment_completed'; // Replace with your actual field name

     if (currentState.toString() == '-5') { // Assuming 'New' state value is '-5'
   
        g_form.setVisible(fieldName, isChangeManager);
     
    } else {
        g_form.setVisible(fieldName, true);
   
    }
}
}
 
It shows the field for ITIL users as well.

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @SajithM 

 

Are you referring to risk assessment? 

*************************************************************************************************************
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]

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