URGENT: Query Business Rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2024 01:14 AM
Hi Community,
I need your assistance in achieving the below requirement without causing any issues with the existing functionality.
When the user submits "Apple iPad" request, it should only visible to him/her and to a specific group where they can work on this request.
Currently all ITIL and other users are able to access these items without any restriction.
I can't utilize ACL's due to that fact that the other existing functionality may not work as there are nearly 7K+ items and they follow their own security.
When writing a query BR, I am able to control the visibility to only specific group but the requested for user is not able to see his own request for the "Apple iPad" item.
Thank you
LakshmiK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2024 02:20 AM
@Anirudh Pathak please check above.
Tried different approaches without any success
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2024 02:24 AM
Hello @LakshmiK -
Please try below code:
var groupID = 'GROUP_ID_HERE'; // Replace with the actual group ID
var userGrp = new GlideRecord('sys_user_grmember');
userGrp.addQuery('user', gs.getUserID());
userGrp.addQuery('group', groupID);
userGrp.query();
var requestedUser = current.getValue('requested_for'); // Assuming 'requested_for' is the field name
var currentUser = gs.getUserID();
if (userGrp.next() || requestedUser == currentUser) {
current.addEncodedQuery('cat_item='+// sys_id_cat_item);
}
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks,
Pratiksha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2024 02:31 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2024 02:43 AM
Hello @LakshmiK -
Please try below code:
var groupID = 'cfcbad03d711110050f5edcb9e61038f'; // Replace with the actual group ID
var userGrp = new GlideRecord('sys_user_grmember');
userGrp.addQuery('user', gs.getUserID());
userGrp.addQuery('group', groupID);
userGrp.query();
var requestedUser = current.getValue('requested_for'); // Assuming 'requested_for' is the field name
var currentUser = gs.getUserID();
if (userGrp.next() || requestedUser == currentUser) {
current.addEncodedQuery('cat_item=899315cd97e04a105e4ff141f053afbd'); //replace with your catalog item sys_id
}
else{
current.addEncodedQuery('cat_item!=899315cd97e04a105e4ff141f053afbd'); //replace with your catalog item sys_id
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2024 04:59 AM - edited 03-04-2024 05:00 AM
Hi @LakshmiK ,
Please try the below code -
if (!gs.getUser().isMemberOf('your group sys_id')) {
current.addEncodedQuery('cat_item=your cat item sys_id^ORopened_byDYNAMIC90d1921e5f510100a9ad2572f2b477fe^ORrequested_forDYNAMIC90d1921e5f510100a9ad2572f2b477fe');
}
Have a look at the below screenshots to generate the encoded query, then you can directly copy query and paste that query -
After Running the above filter-
Note : Make sure to copy the query from clicking on the right most filter.