Query Business rule not working

David Cross
Tera Expert

Hello All, 

I have a requirement that only the group members and opened by users must be able to view the ritm. 

But  br code is not working can you please help me here. 

 

I have attached my code 

3 REPLIES 3

Brad Bowman
Kilo Patron
Kilo Patron

Hi David,

Keep in mind that the Condition is going to cause the BR/script to run only if the current user is not a member of that group, so all RITMS will be shown to members of this group.  If this is not what you want to do, remove the Condition all-together to start with, or modify it accordingly.

  

In the script, try something more like this to only show RITMs where the current user is the one who opened it, OR the assignment group is empty OR the assignment group is not the one from the system property - or change this encoded query to whatever you're trying to accomplish:

 

var u = gs.getUserID();
var grp = gs.getProperty('MyPortal_AssignmentGroup_HRSystem');
var query = 'assignment_groupISEMPTY^NQassignment_group!=' + grp + 
'^NQopened_by=' + u;
current.addEncodedQuery(query);

 

 

Thank you Brad for your reply. 

I'll try this and will update you here... 

Hello Brad, i have made this changes; This is working for me

 

var u = gs.getUserID();
var grp = gs.getProperty('MyPortal_AssignmentGrp_HRSystem');

var q = current.addNullQuery('assignment_group');
q.addOrCondition('opened_by', u);
q.addOrCondition('assignment_group', '!=', grp);

gs.log("query restricted to user: " + u);