
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2019 06:29 AM
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);
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2019 07:32 AM
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2019 06:42 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2019 07:32 AM
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);