Client Script usecase

AkashKushwah
Tera Contributor

I have a use case for client script in ServiceNow and i also write script for that but it is not running properly. can anyone help me to find what is wrong in this script.

 

Disable a field for specific roles
Use Case: Disable the "Assignment Group" field for users without the ITIL role.

 

script ---

function onLoad() {
   //Type appropriate comment here, and begin script below
   if(!g_user.hasRole("itil")){
    g_form.setDisabled('assignment_group',true);
   }
   else{
    g_form.setDisabled('assignment_group',false);
   }
}
1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@AkashKushwah 

script looks fine

Did you add alert and see?

any UI policy is doing the reverse?

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

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

View solution in original post

1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

@AkashKushwah 

script looks fine

Did you add alert and see?

any UI policy is doing the reverse?

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

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