URGENT: Query Business Rule

LakshmiK
Tera Contributor

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

9 REPLIES 9

LakshmiK
Tera Contributor

@Anirudh Pathak  please check above.

Tried different approaches without any success

Pratiksha2
Mega Sage

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

Hi @Pratiksha2 

 

Thanks for your quick response but the above is not helping.

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
}

Anirudh Pathak
Mega Sage

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 - 

ani07_0-1709556851459.png

 

After Running  the above filter-

ani07_2-1709556873653.png

Note : Make sure to copy the query from clicking on the right most filter.