Make field read only to everyone and editable for 'user_admin' role

Sanket Choughul
Tera Contributor

Hi Community,

I have created a new field 'termination date' in user table. I have a requirement to make this field read-only for itil user and editable for 'user_admin' role through ACL. 

9 REPLIES 9

Then ACLs might be conflicting , please create onload client as suggested by @Ankur Bawiskar  , Deleting my script as BR is not required.

Regards

Please hit like and mark my response as correct if that helps
Regards,
Musab

Sourabh26
Giga Guru

Hi,

 

Create a field level ACL for this on the user table.

Write ACL

User.termination_date 

Add role (user_admin)

 

Mark this as Helpful/Correct, if Applicable.

 

Regards,

Sourabh

Hi Sourabh,

I have tried the same earlier but it's not working.

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

So did you perform ACL debugging?

Regards
Ankur

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

@Sanket Choughule 

Don't use any ACL

you can simply use onLoad client script and no BR is required

function onLoad() {

	if (g_user.hasRoleExactly('itil')){ 
		g_form.setReadOnly('termination_date', true);
	}
	else if(g_user.hasRoleExactly('user_admin')){
		g_form.setReadOnly('termination_date', false);
	}

}

Regards
Ankur

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