Convert ACL to before query BR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2024 08:51 PM
can anyone help me to convert the ACL code into before query BR.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2024 09:03 PM
Below is the sample before query BR you can modify:
(function executeBeforeQuery(current, previous /*null when async*/) {
// Check if the session is interactive and not impersonating
if (gs.getSession().isInteractive() && (new sn_hr_core.hr_CoreUtils().impersonateCheck())) {
return;
}
// Instantiate hr_Case object
var hrCase = new hr_Case(current, gs);
// Check if the current user can read the case
if (hrCase.canReadCase()) {
current.addActiveQuery();//you can write your own logic here
}
})(current, previous);
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2024 06:57 PM
Hello sunil,
I am aware of using the addActiveQuery(). But the hrCase.canReadCase() do lot of validations like it can check the user has respective roles, weather any of the COE security policies met with the respective user.
I can include roles in the activequery() but what about COE security policies, how I can set it in the query
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2024 12:03 AM
Hi @Ak8977 ,
Can you please try this:
(function executeBeforeQuery(current, previous /*null when async*/ ) {
var answer = false;
if (gs.getSession().isInteractive() && (new sn_hr_core.hr_CoreUtils().impersonateCheck())) {
gs.log("Impersonate check failed. Access denied.");
} else if (new hr_Case(current, gs).canReadCase()) {
answer = true;
} else {
gs.log("User does not have permission to read the case. Access denied.");
}
if (!answer) {
current.setLimit(0);
}
})(current, previous);
Please modify the script as per your logic requirements.
Please mark this response as helpful if your question has been answered correctly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2024 06:53 PM
Hello Dipesh it won't work. In query business rule we have to use addQuery() or addEncodedQuery().