Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

check logged in user has approval role

foramp
Giga Contributor

If logged-in user does NOT have Travel Approver role, make Approval Remark field read-only

2 REPLIES 2

GlideFather
Tera Patron

Hi @foramp,

 

could you possibly explain the process exactly? It will vary whether it is in client or server side.

 

there's the method 1) hasRole('itil') and 2) hasRoleExactly('itil') - difference is in inheritance, admin will be 1) true and 2) false....

 

so based on what you want to achieve then you will apply this accordingly.

 

_____
100 % GlideFather experience and 0 % generative AI

Ankur Bawiskar
Tera Patron

@foramp 

use this and give correct field name and role name

function onLoad() {
    //Type appropriate comment here, and begin script below

    g_form.setReadOnly('approval_remark', !g_user.hasRoleExactly('travel_approver')) // your field name here

}

OR

You can use field level WRITE ACL on that Field and give Travel Approver role in roles section

 💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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