Need to write an ACL to allow only members of particular group to edit few fields in location table

Kayathri
Tera Contributor

Hi Team,

 

Having a requirement to write a ACL to allow only members of a particular group to edit three user defined fields in location table. Kindly suggest.

 

Regards,

Kayathri

1 ACCEPTED SOLUTION

Hi,

so members of that group should be allowed editing only 3 fields

All others should be readonly

Do this

Display BR on your table:

g_scratchpad.isMember = gs.getUser().isMemberOf('Group Name');

onLoad Client Script:

function onLoad(){

	if(g_scratchpad.isMember.toString() == 'true'){

		// make all fields readonly
		var fields = g_form.getEditableFields();
		for (var x = 0; x < fields.length; x++) {
			g_form.setReadOnly(fields[x], true);
		}

		// make those 3 fields as editable
		g_form.setReadOnly('fieldA', false);
		g_form.setReadOnly('fieldB', false);
		g_form.setReadOnly('fieldC', false);
	}

}

Regards
Ankur

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

View solution in original post

11 REPLIES 11

Anil Lande
Kilo Patron

Hi,

You need to create a Write ACL for the table_name.field_name. SO you need to create three ACL's for three fields.

In your ACL script you can check gs.isMemberOf('GroupName/Sys_id') to check whether user is member of particular group.

If user is member of group set answer=true else answer=false

 

Thanks,
Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Ankur Bawiskar
Tera Patron
Tera Patron

@Kayathri 

As mentioned by Anil you can use 3 field level WRITE ACLs on individual fields.

OR

If you don't want to create 3 ACLs then you can take Display BR + Client Script approach

Display BR: it would check if logged in user is member of particular group and store in g_scratchpad

onLoad Client Script: it would get the scratchpad variable value and based on true/false allow edit of those 3 fields on form

Regards
Ankur

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

Hi Ankur,

I have the requirement that the three fields should be editable by the members of the particular group, so I have written a table level ACL to make that edit all the fields,3  field level ACLs also written, since only the members of those group should access those 3 fields, not other members. now I want to restrict the group members to edit only the three fields. Please suggest how it can be done.

 

Regards,

Kayathri

Hi,

so members of that group should be allowed editing only 3 fields

All others should be readonly

Do this

Display BR on your table:

g_scratchpad.isMember = gs.getUser().isMemberOf('Group Name');

onLoad Client Script:

function onLoad(){

	if(g_scratchpad.isMember.toString() == 'true'){

		// make all fields readonly
		var fields = g_form.getEditableFields();
		for (var x = 0; x < fields.length; x++) {
			g_form.setReadOnly(fields[x], true);
		}

		// make those 3 fields as editable
		g_form.setReadOnly('fieldA', false);
		g_form.setReadOnly('fieldB', false);
		g_form.setReadOnly('fieldC', false);
	}

}

Regards
Ankur

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