Condition on a Before Query Business Rule ?

Anthony Grau
Giga Guru

Hello,

I added a True/False field to the incident form, named u_confidential.

I try to restrict the access to the record by:

1 - Role ('security_officer')

OR

2 - User (assigned to the record)

My script seems to work fine while the condition cancel the execution.

Could you tell me which condition could do the job ?

Condition so far (not working): current.u_confidential == true

Business Rule (Before, Query):

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

if(!gs.hasRole("security_officer") /*&& gs.isInteractive()*/) {
var u = gs.getUserID();
var qc = current.addQuery("assigned_to",u);
gs.log("query restricted to user: " + u, 'AG');
}
})(current, previous);

1 ACCEPTED SOLUTION

Anthony Grau
Giga Guru

I'd like to thank you for your interest.

I finally found a solution that I share with the community. (with encoded querry via filters)

 

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

if(!gs.hasRole("security_officer") /*&& gs.isInteractive()*/) {
var u = gs.getUserID();
var qc = current.addEncodedQuery("assigned_to="+u+"^u_confidential=true^NQu_confidential=false");
gs.log("query restricted to user: " + u, 'AG');
}
})(current, previous);

View solution in original post

2 REPLIES 2

Prateek kumar
Mega Sage

Can you try this

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

if(!gs.hasRole("security_officer") && gs.getSession().isInteractive()) {
var u = gs.getUserID();
var qc = current.addQuery("assigned_to",u);
gs.log("query restricted to user: " + u, 'AG');
}
})(current, previous);

Please mark my response as correct and helpful if it helped solved your question.
-Thanks

Anthony Grau
Giga Guru

I'd like to thank you for your interest.

I finally found a solution that I share with the community. (with encoded querry via filters)

 

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

if(!gs.hasRole("security_officer") /*&& gs.isInteractive()*/) {
var u = gs.getUserID();
var qc = current.addEncodedQuery("assigned_to="+u+"^u_confidential=true^NQu_confidential=false");
gs.log("query restricted to user: " + u, 'AG');
}
})(current, previous);