Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Client Script usecase

AkashKushwah
Tera Expert

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

@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  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

1 REPLY 1

Ankur Bawiskar
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  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader