Business rule to restrict ticket visibility but can still submit and see records

Pat Surtan
Tera Expert

Hi,

 

I created a before query business rule to restrict ticket visibility to only users in their groups. I have 3 custom tables so this works perfectly to show the tickets you have access to based on the assignment group you're in. However, I get an error from 2 of the tables when I submit a record producer that uses those 2 tables. The other table works fine. When I disable this business rule, I can see the records I submitted but users will lose that restriction and can see ALL tickets, which is not what I want. Here is my script:

 

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

  
    var u = gs.getUserID();

        if((!u.isMemberOf(current.assignment_group)) && gs.getSession().isInteractive()){

    var q = current.addQuery('assignment_group', getMyGroups());   
    
}

})(current, previous);

 

What is wrong with my code? How do I allow users to see the records they submitted for the other 2 tables?

1 ACCEPTED SOLUTION

Hi Abhay,

what do you mean it allows all records? My script works fine to show only tickets that are assigned to a person's group. But I am having problems viewing the ticket from the Service Portal after it is submitted because of the error I posted.

View solution in original post

3 REPLIES 3

Abhay Kumar1
Giga Sage
Hi Pat, It seems you JS throws some error and allowing all records. Please check this line out current.addQuery('assignment_group', getMyGroups()); and try to use current.addQuery('assignment_grouo','IN',getMyGroups()). Hope this will help.

Hi Abhay,

what do you mean it allows all records? My script works fine to show only tickets that are assigned to a person's group. But I am having problems viewing the ticket from the Service Portal after it is submitted because of the error I posted.

I found my answer. I need to add ("requested_by",u) to my query to allow users to see tickets they submitted.