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

Anirudh Pathak
Mega Sage

Hi @LakshmiK ,

Can you share your code?

Did you add a condition to check if "requested for" is currently logged in user or not.

If not try the below code - 

var loggedUser= gs.getUserID();
current.addQuery("requested_for", loggedUser).addOrCondtion("Your group condition");

 

Hi @Anirudh Pathak 

 

I have added that but it still did not work hence seeking assistance here.


Hi @LakshmiK ,

can you share your code which you have tried till now?

1 Version:

var currentUser = gs.getUserID();

current.addQuery("opened_by",'!=', 'currentUser') .addorCondition("requested_for",'!=', 'currentUser').addorCondition (!gs.getUser().isMemberOf('R799684440730021098b3f61d7c1ed047IT')  {

current.addEncodedQuery("cat_item!=73b1bafa9752cd1021983d1e6253afb5");

 

2. Version:

 

    if (!checkGroup())
            current.addQuery(current.cat_item.name != '73b1bafa9752cd1021983d1e6253afb5'); //Or point the the sys_id of that specific catalog item

        function checkGroup() {
            var grpMember = new GlideRecord('sys_user_grmember');
            grpMember.addQuery('user', gs.getUserID());
            grpMember.addQuery('group.type', '9337011e1b055910bbb1a8afe54bcb24');
            grpMember.query();
            return grpMember.hasNext();
        }
            current.addQuery('cat_item.name', 'Apple iPhone 13 pro');