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-27-2022 11:02 PM
In which table you written this BR? did you try using sys_class_name from task table ?
Thanks & Regards,
Vasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-27-2022 11:18 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-27-2022 11:27 PM
Try the below code,
var currentTaskNum = current.task.number;
if (!gs.hasRole('admin')) {
if (currentTaskNum.startsWith('PRJ') == true)
current.addEncodedQuery('task.ref_pm_project.project_manager=' + gs.getUser().getID());
}
Thanks & Regards,
Vasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-27-2022 11:55 PM
Hi,
I have tried this already and currentTaskNum is not giving any value.
Thanks,
Pavan