Business Rule trigger issue

Bijay Kumar Sha
Giga Guru

Hi,

I've a form as per attached screenshot -

BijayKumarSha_0-1697458528255.png

 

 

You can see the highlighted in green color Compliance Flag which are in 'Complete' state which makes the over all Compliance status as 'Complete'. However, in the attached screenshot, you can see overall all Compliance status as 'Overdue' instead of 'Complete'.

 

There is a BR for the same to toggle the overall Compliance status between 'Complete' and 'Overdue' which is I'm sharing as below -

 

(function executeRule(current, previous /*null when async*/ ) {
//u_well_architected_status , u_security_status , u_exit_strategy_status
// If any of the status changes then update Complaince status
if (current.u_risk_status == 'Overdue' || current.u_material_status == 'Overdue' || current.u_dpia_status == 'Overdue' || current.u_architecture_status == 'Overdue' || current.u_well_architected_status == 'Overdue' || current.u_security_status == 'Overdue' || current.u_exit_strategy_status == 'Overdue') {

current.u_compliance_status = 'Overdue';

} else if (!current.u_risk_status.nil() && !current.u_material_status.nil() && !current.u_dpia_status.nil() && !current.u_architecture_status.nil() && !current.u_well_architected_status.nil() && !current.u_security_status.nil() && !current.u_exit_strategy_status.nil()) {

current.u_compliance_status = 'Complete';
}

current.setWorkflow(false);
current.update();
current.setWorkflow(true);

})(current, previous);

 

I further debug and found that, there might be the reason as below -

Under Compliance tab section, there are different Compliance status are there. And these different sections are getting show/hide depending upon another field value which is 'Workload Environment' which is Production or non-Production or Sandbox.   

I guess, let's say there are total 6 different Compliance status in a form and as per the UI Policy, for Non-Production it's showing up 5 different Compliance status on the form. And all these 5 Compliance status are Complete but the one which is in Hide is overdue which is making the over all compliance status as Overdue. 

 

So, what changes I need to make in the BR to avoid such things

3 REPLIES 3

AnveshKumar M
Tera Sage
Tera Sage

Hi @Bijay Kumar Sha 

In your screenshot there are only four status fields but in BR condition it is checking for almost 7 fields. Are those 7 fields status is also completed?

 

The code looks fine, except the current.update(), try to avoid it. Use before BR and set the value instead of current.update().

Thanks,
Anvesh

Hi @AnveshKumar M ,

That is the issue as I mentioned. There are total 7 fields for compliance status and accordingly the overall Compliance Status is getting updated as 'Complete' or ;Overdue'. However, depending upon other fields there may be 4 fields will get visible and other are hidden or sometimes, 6 fields will get visible on the form and others hidden. 

How to handle this situation? 

There might be chance, the fields which got hidden, that value might be Overdue, which is making the overall compliance status as overdue. 

@Bijay Kumar Sha Thanks for the confirmation!

 

In that case you should check for multiple combinations (multiple else-if conditions) which are all possible.

Thanks,
Anvesh