Before query business rule based on current record values

Pavan Yakkala1
Kilo Explorer

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

20 REPLIES 20

Vasantharajan N
Giga Sage
Giga Sage

In which table you written this BR? did you try using sys_class_name from task table ?


Thanks & Regards,
Vasanth

Hi Vasantharajan,

Thanks for reply. Am trying this on table 'Risk' and getting the value of task number and task type etc.. in before query business rule

 

find_real_file.png

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

Hi,

I have tried this already and currentTaskNum is not giving any value.

Thanks,

Pavan