Intermittently, incorrect value is being populated on metric_instance record.
For example, lets say we have a "metric_definition" defined for "Assignment Group" field on incident table.
As per this "metric_definition", when there is a change with the "Assignment Group" field on an incident record, system should create a new "metric_instance" record with the new value of "Assignment Group" field.
When the "Assignment Group" value is changed from "Group A" to "Group B", the newly created "metric_instance" record should have value as "Group B". However, intermittently, "metric_instance" record created with old value "Group A" instead of "Group B".
This article will brief on the possible reason for this incorrect behavior of the system.
Any supported release.
The out of the box provided "metric events" before insert/update business rule is set to run just before the database insert/update is being made on task record. This is done via setting the order as "10,000".
However, if there are any other custom before insert/update business rule set up on task table with order as "10,000" or higher and if that takes longer time to execute ( for example longer than 3 seconds), the metric records would have been created before the actual insert/update are being fired on database level.
Hence, the newly created metric instance record would have incorrect value. For example, "Group A" instead of "Group B".
Make sure the "Metrics event" business rule is the last before insert/update business rule to run just before firing insert/update on database level.
This can be achieved via setting highest order to "Metrics event" business rule than any other "before insert/update business rule" on task table.