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

Ian Mildon
Tera Guru

What are the "When" settings on both Business Rules?

Both "Before"

Set the second one to "after". Now the first one has a chance to set it, and the database is updated for the second to see the update.

Unfortunately I did try that and it didn't work.