Show incident rows only to the assignment group

shany_b
Kilo Contributor

Hi,

Is there a way to define that only the assignment group could see her incident rows?

I tried to write an ACL:

Operation: read

script:

if(gs.getUser().isMemberOf(current.assignment_group))

{

answer=true;

}

else

{

answer=false;

}

however, the group members can't see any of the records (i attached a screenshot)acl.png

The member that i impersonated should have seen the first 3 rows

Also - I want the ones that are not in the assignment group to not see the records at all - instead of these empty records

Thank you in advance

10 REPLIES 10

Jaspal Singh
Mega Patron
Mega Patron

Hi Shany,



Script looks fine could you just personalize the list


find_real_file.png


& add more columns & check if records are displayed.


Hi Jaspal,



the records are not disply - the ones the user should see and the ones he souldn't


Ankur Bawiskar
Tera Patron
Tera Patron

Hi Shany,



I think when you have script section and it results to false it won't show data in that columns but it will show empty values.


Best way to do this is have before query business rule.



https://www.servicenowguru.com/scripting/business-rules-scripting/controlling-record-access-before-q...


https://servicenowgems.com/2015/07/29/tip-for-creating-complex-before-query-business-rules/



What this will show only those records where assignment group belongs to user's group



Business rule condition: // this ensures that whenever this table is queried from any script the business rule won't run and won't restrict the records


gs.getSession().isInteractive()



Script:


var myUserObject = gs.getUser();


      var myUserGroups = myUserObject.getMyGroups();


      var groupsArray = new Array();


      var it = myUserGroups.iterator();


      var i=0;


      while(it.hasNext()){


              var myGroup = it.next();


              groupsArray[i]=myGroup;


              i++;


      }



var qc = 'assignment_group.sys_idIN'+groupsArray;


current.addEncodedQuery(qc);



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


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

Hi Ankur,



I tried this business rule but nothing happends - the user can see all incidents,


I also tried the ones in the link



what can be the source of the problem?



Thank you