Access control help

Andrew_TND
Mega Sage
Mega Sage

I've created a "READ" access control which has worked...ish. For some reason its now showing a blank placeholder where the record should be, any ideas how I can just remove this completely?

I did try and configure it instead however the dynamic "is one of my groups" didnt seem to work so had to go down the scripting route.

Andrew_TND_0-1735559547254.png

Andrew_TND_1-1735559675736.png


Script condition

 

answer = true;

if (current.u_nda) {
	var group = current.u_authorized_group;

	if (!gs.getUser().isMemberOf(group)) {
		answer = false;
	}
}

 

1 ACCEPTED SOLUTION

Andrew_TND
Mega Sage
Mega Sage

Hey all, I managed to get it working using "addEncodedQuery()" which is actually really simple.

 

//When to run: Before
//Order: 1000
// Query: True

(function executeRule(current, previous) {
    var query = '';
    query = "u_authorized_groupDYNAMICd6435e965f510100a9ad2572f2b47744^ORu_authorized_groupISEMPTY";
    current.addEncodedQuery(query);
})(current, previous);

 


Thank you everyone for your help! 

View solution in original post

14 REPLIES 14

Harish Bainsla
Kilo Patron
Kilo Patron

Hi @Andrew_TND  try below script 

answer = true;

if (current.u_nda) {

 var group = current.u_authorized_group;

if (group && !gs.getUser().isMemberOf(group)) {

answer = false;

Ankur Bawiskar
Tera Patron
Tera Patron

@Andrew_TND 

you should also give table.None READ ACL

What should happen if that group is empty?

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

Ankur Bawiskar
Tera Patron
Tera Patron

@Andrew_TND 

is one of my groups should work fine provided that field holds a reference to group table

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

Andrew_TND
Mega Sage
Mega Sage

Hi @Harish Bainsla & @Ankur Bawiskar, the script doesnt seem to have any issues its more the blank row it generates if a record is being hidden if you know a way to remedy that?