Make assignment group and assigned to fields editable only to Admin and ITIL.

SBohare
Tera Contributor

The following is the Script I wrote for the above problem It doesn't seem to work. I want feed back. 

function onLoad(){
// condition to check roles of user
// other than users with roles ITIL
if( ! (g_user.hasRoleExactly("itil") || g_user.hasRoleExactly('admin') ) ){
// setting to readonly
g_form.setReadOnly('assignment_group',true);
g_form.setReadOnly('assigned_to',true);
}
}

2 ACCEPTED SOLUTIONS

Ankur Bawiskar
Tera Patron
Tera Patron

@SBohare 

why not use field level WRITE ACLs on those individual fields?

update script as this

function onLoad(){
	// condition to check roles of user
	// other than users with roles ITIL
	if(!g_user.hasRoleExactly("itil") && !g_user.hasRoleExactly('admin')){
		// setting to readonly
		g_form.setReadOnly('assignment_group',true);
		g_form.setReadOnly('assigned_to',true);
	}
}

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

Shamma Negi
Kilo Sage
Kilo Sage

Try this field level ACL with script. It should work

ShammaSalhotra_1-1676975063688.png

 

 

Regards,Shamma Negi

View solution in original post

7 REPLIES 7

@SBohare 

Thank you for marking my response as helpful.

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

@SBohare 

Please close the thread by marking response as correct.

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

Shamma Negi
Kilo Sage
Kilo Sage

Try this field level ACL with script. It should work

ShammaSalhotra_1-1676975063688.png

 

 

Regards,Shamma Negi