- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2021 05:30 AM
here we have ritm records which needs to hide if the user is not part of "IT" team.
we tried to hide through ACL but not working as expected , field are getting hide but not the complete record.
here the ACL for reference:
if(gs.getUser().isMemberOf("IT")){
answer =true;
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2021 09:51 PM
Hi,
Okay so you want this
1) if user is member of IT then show records where u_hr=true
2) if user is not member of IT then show records where u_hr=false
then update the BR as this
Condition: gs.getSession().isInteractive()
Script:
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
if(gs.getUser().isMemberOf("IT"))
current.addEncodedQuery("u_hr=true");
else
current.addEncodedQuery("u_hr=false");
})(current, previous);
Let me know if I have answered your question.
If so, please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2021 06:03 AM
hi Roxi,
Yes , query BR perfectly fits in here. It can filter the data when query is made to db. Here is the sample
if (!gs.getUser().isMemberOf('IT') )
current.addEncodedQuery('assignment_group.name!=IT')
Additional you may include some other conditions such as , if user is admin filter shouldn't work etc.
Mark "Helpful / correct answer" if this helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2021 06:45 AM
can we alter the ACL to make work the same requirement?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2021 07:00 AM
Hello Roxi,
You can do a script within the UI Policy
function onCondition() {
var grpName = '205fac11db606b04fe86fd641d9619ff'; //Group SysID
var usrID = g_user.userID;
var grp = new GlideRecord('sys_user_grmember');
grp.addQuery('group', grpName);
grp.addQuery('user', usrID);
grp.query(groupMemberCallback);
function groupMemberCallback(grp){
if(grp.next()){
g_form.setVisible('u_conference_call_needed', false); // you can put your item name
g_form.setVisible('u_is_an_escalation_needed', false);
}
}
}
This will hide fields if you did SetVisible .
Please make Correct or helpful if this helps!
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2021 07:24 AM
hello sony,
thanks for your reply, but we are not looking to hide fields , but hide the complete record