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

Client Script – Approval Remark Control

foramp
Giga Contributor

1.If logged-in user does NOT have Travel Approver role, make Approval Remark field read-only.
 2. Users with approver role should be able to edit it

4 REPLIES 4

Rafael Batistot
Kilo Patron

Hi @foramp 

 

function onLoad() {
g_form.setReadOnly(
'approval_remark',
!g_user.hasRole('travel_approver') ? true : false
);
}

If you found this response helpful, please mark it as Helpful. If it fully answered your question, consider marking it as Correct. Doing so helps other users find accurate and useful information more easily.

Aditya_hublikar
Mega Sage

Hello @foramp ,

 

Please refer this code :

 

function onLoad() {
   //Type appropriate comment here, and begin script below
    if(!g_user.hasRoleExactly('itil'))//add your required role here
	{
		g_form.setReadOnly('u_short_description',true)//add your required field here
	}
}

 

cs1.png   cs2.png

 

If this helps you then mark it as helpful and accept as solution.

Regards,

Aditya

 

@foramp 

Hope you are doing good.

Did my reply answer your question?

💡 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

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

}

💡 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