Limit ITIL access to tickets assigned to their group AND when they are the caller

Abbie4
Tera Contributor

Hello

 

I have a business rule setup on incidents which limit some ITIL users to only see tickets assigned to their assignment group:

if(gs.getUser().isMemberOf("GROUPNAME")){
 current.addEncodedQuery("assignment_group=GROUPSYS_ID");
 
However I also want them to be able to see tickets where they are the caller, regardless of which assignment group the ticket is assigned to. I can't seem to get it to work using the same business rule.
 
Help?

Thanks
Abbie
1 ACCEPTED SOLUTION

 Please use the below code and check if this works for you.

if (gs.getUser().isMemberOf('Group_Name')) {
current.addEncodedQuery("caller_idDYNAMIC90d1921e5f510100a9ad2572f2b477fe^ORassignment_group=group_sysid^ORwatch_listLIKEjavascript:gs.getUserID()");
}

 

 

View solution in original post

10 REPLIES 10

Hello, 

 

The script above gives me a syntax error, which I can only seem to get past by added } before the else if, but then this still doesn't work. The assignment groups work, but not the self-service of being able to see their own tickets when they are the caller.

 

if (gs.getUser().isMemberOf('Group_Name')) {
		current.addEncodedQuery('numberISNOTEMPTY^assignment_group=group_sysid');
 } else if
    ('caller_id=' + gs.getUserID() + '^ORwatch_listLIKE' + gs.getUserID());
        current.addEncodedQuery('numberISNOTEMPTY');

})(current, previous);

Abbie4
Tera Contributor
if (gs.getUser().isMemberOf('Group_Name')) current.addEncodedQuery('numberISNOTEMPTY^assignment_group=group_sysid'); else if ('caller_id=' + gs.getUserID() + '^ORwatch_listLIKE' + gs.getUserID()); current.addEncodedQuery('numberISNOTEMPTY'); })(current, previous);

 Managed to get rid of the syntax error and the { } but I have the same issue with script above. Tickets are still locked down by assignment group, but I am unable to see tickets when they are the caller still. 

Why not add the condition to the query?

(function executeRule(current, previous /*null when async*/) {
    if (gs.getUser().isMemberOf('Group_Name')) {
        current.addEncodedQuery('numberISNOTEMPTY^assignment_group=group_sysid');
    } else {
        current.addEncodedQuery('numberISNOTEMPTY^caller_id=' + gs.getUserID() + '^ORwatch_listLIKE' + gs.getUserID());
    }
})(current, previous);

 


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Hi Abbie,

 

Could you please just try this below code.

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


current.addEncodedQuery("caller_idDYNAMIC90d1921e5f510100a9ad2572f2b477fe^ORassignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744^ORwatch_listLIKEjavascript:gs.getUserID()");


})(current, previous);

That works if I want to restrict everyone's access, but I only want to restrict a specific assignment group. 

 

I have one assignment group who are only allowed to see their own tickets: this includes tickets where they are the caller or tickets assigned to the assignment group they are a member of.

 

All other ITIL users in other assignment groups, apart from the one above, should be able to continue to see all tickets.