Business rule is running before field change on another table

Farah5
Tera Contributor

I have a problem that is really confusing me. We have a table (Business Process) that generates a risk assessment for users to complete. Sometimes it can be multiple risk assessments. When an assessment is complete (State = Complete), I have one Business Rule that sets a date value on the Business Process table (the table the assessment is tied to).

Now, I have a second Business Rule, that checks that this date field changes and is not empty. The second BR checks ALL Risk Assessments associated with that particular record, and completes an action only if all records have a State of Complete. However, whenever I run this second BR, it's telling me that the Risk Assessment state is still sets as "Ready" and not "Complete". It is running though, which means that the date value was changed, which means that the Risk Assessment state was changed to Complete. The second BR will not run until the date value changes. So why is it still seeing this related record's old state value?

 

BR #1: (runs on the Risk Assessment table)

find_real_file.png

It queries the Business Process table and then sets the date value: 

var businessProcessGR = new GlideRecord('cmdb_ci_business_process');
businessProcessGR.addQuery('sys_id', current.u_business_process);
businessProcessGR.query();

if( businessProcessGR.next() ){
businessProcessGR.u_assessment_completion_date = new GlideDate();
businessProcessGR.update();
}

 

BR #2: (runs on the Business Process table)

find_real_file.png

It queries all Risk Assessments associated with this record, checks if there are any records that still have a State = Ready, and if not, sets a field value to true. 

find_real_file.png

 

I'd appreciate any advice anyone can offer. 

8 REPLIES 8

Then maybe change the run "order" on the second so it is distinctly running after the first. So, if they are both at the default value of 100, change the second BR to say 300 (or greater).

Now it will have less chance of getting ran "out of order" as everything in the 100 range gets run in a "first come" manner and the sequencing cannot be predicted.

Hm I did try that as well and it didn't work. But order doesn't seem to be an issue anyways, since BR #2 won't run at all unless the field that is changed by BR #1 is populated. And it is running every time.

Jaspal Singh
Mega Patron
Mega Patron

Make Business Rule no. 2 should to run After & not Before then.

Additionally, you can add condition of State Change as in BR no.1

Hi, no unfortunately changing BR #2 to run After did not do anything. And the BR #1 already has a condition of State Change.