Before query business rule based on current record values
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2022 10:18 PM
Hi Team,
The requirement is to limit the read of records based on a role and current task type.
For example, Risks should be displayed only if type is Project and he is project manager. For this, we need to check whether task type is Project or not from Risk table and before query business rule.
But it seems we are not able to get the task reference values in before query business rules.
Can you help with how to do this?
Please find the script in before query business rule
var currentTask = current.task.getRefRecord();
var currentTaskNum = currentTask.number;
//gs.info('##Hello:::::'+currentTaskNum); //giving empty value
if (!gs.hasRole('admin')) {
if (currentTaskNum.startsWith('PRJ') == true)
current.addEncodedQuery('task.ref_pm_project.project_manager=' + gs.getUser().getID());
}
Thanks in advance
Kind regards,
Pavan
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2022 01:06 AM
Hi Shloke,
Thanks for reply. There are other reasons why we are not going with ACLs. Restriction of visibility depends on various conditions and on various tables. Hence, preferred to go with before query business rule. But, the problem here it seems we can't get the values of current record and current record reference fields especially in before query business rule.
Any pointers/help would be much appreciated towards this
Thanks,
Pavan