Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

Only opened by should able to see RITM not other how to restrict

s_nandhini
Tera Contributor

Hi All,

 

I have a requirement only opened by should able to see the Req and RITM not other even requested for should not able to see the request for particular catalog item.

 

I tried restricted via ACL and Query BR but still requested for and other ITIL users able to see the RITM and REQ.

 

Please guide me which is the best approach.

1 ACCEPTED SOLUTION

@s_nandhini 

you can enhance that

something like this

(function executeRule(current, previous /*null when async*/ ) {

    if (!gs.getSession().isInteractive() || gs.hasRole('admin')) {
        return;
    }

    var catItemId = 'PUT_CATALOG_ITEM_SYS_ID_HERE';
    var allowedGroupId = 'PUT_GROUP_SYS_ID_HERE';
    var userId = gs.getUserID();

    // If user is in the allowed group, allow full access to this catalog item's RITMs
    if (gs.getUser().isMemberOf(allowedGroupId)) {
        return;
    }

    // For the restricted catalog item:
    // show only records where request.opened_by is current user
    // all other catalog items remain visible as usual
    current.addEncodedQuery(
        'cat_item!=' + catItemId +
        '^NQcat_item=' + catItemId + '^request.opened_by=' + userId
    );

})(current, previous);

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

 

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

23 REPLIES 23

@s_nandhini 

Hope you are doing good.

Did my reply answer your question?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar 

Yes, it working fine for RITM. Can i add particular group in the same script.So opened by and particular group will have access to RITM and REQ.

 

@s_nandhini 

Glad to know that my script for Query BR worked for RITM.

Could you mark my response as correct and close the thread and discussion can continue on answered thread as well?

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

@s_nandhini 

you can enhance that

something like this

(function executeRule(current, previous /*null when async*/ ) {

    if (!gs.getSession().isInteractive() || gs.hasRole('admin')) {
        return;
    }

    var catItemId = 'PUT_CATALOG_ITEM_SYS_ID_HERE';
    var allowedGroupId = 'PUT_GROUP_SYS_ID_HERE';
    var userId = gs.getUserID();

    // If user is in the allowed group, allow full access to this catalog item's RITMs
    if (gs.getUser().isMemberOf(allowedGroupId)) {
        return;
    }

    // For the restricted catalog item:
    // show only records where request.opened_by is current user
    // all other catalog items remain visible as usual
    current.addEncodedQuery(
        'cat_item!=' + catItemId +
        '^NQcat_item=' + catItemId + '^request.opened_by=' + userId
    );

})(current, previous);

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

 

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

For Request, I tried the same but it is not working. Still requested for can able to see the request.