Business rule is running before field change on another table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2022 10:49 AM
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)
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)
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.
I'd appreciate any advice anyone can offer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2022 10:52 AM
What are the "When" settings on both Business Rules?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2022 10:54 AM
Both "Before"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2022 10:55 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2022 10:58 AM
Unfortunately I did try that and it didn't work.