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

check logged in user has approval role

foramp
Tera 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.

 


✂-----Cutting-out-the---✦AI-noise✦---All-replies-written-and-vouched-for-by-GlideFather---

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