- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 03:55 AM - edited 12-30-2024 03:56 AM
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.
Script condition
answer = true;
if (current.u_nda) {
var group = current.u_authorized_group;
if (!gs.getUser().isMemberOf(group)) {
answer = false;
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2025 05:44 AM - edited 01-02-2025 05:45 AM
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 04:46 AM
got it
That's how ACLs work.
If table has 100 records and only 10 satisfy then those 10 records are scattered and user has to scroll to the next page
To overcome this you can use query BR on that table and have similar query
BR Condition: gs.getSession().isInteractive()
Script:
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var groups = new global.ArrayUtil().convertArray(gs.getUser().getMyGroups());
current.addQuery('u_authorized_group', 'IN', groups);
current.addQuery('u_nda', true);
})(current, previous);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 05:23 AM
Hi Ankur, thanks for coming back to me. Unfortunately neither have worked, I'm going to give another crack at it however if you come up with any other ideas in the meantime I'm all ears! 😁
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 05:32 AM
did you try the below script?
Also are you sure you have table.None READ ACL on your table?
Are you having the same issue which I mentioned above i.e. records are scattered on next pages and user has to scroll?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 05:34 AM
Currently its * I did try "None" however it stops working when I do.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 06:02 AM
you should have table.None READ ACL with same advanced script
table.* READ is not required.
Did you create query BR and verify it? did you try the updated query BR?
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var groups = new global.ArrayUtil().convertArray(gs.getUser().getMyGroups());
current.addEncodedQuery('u_nda=true^u_authorized_groupNOT IN' + groups).addOrCondition('u_nda', false);
})(current, previous);
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader