Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2025 05:11 AM
Metric's don't have access to the previous value, only the changed value. I would change your logic to create the metric instance when the state is awaiting acceptance, and close it when in WIP.
//answer and mi are passed in as part of MetricInstance script include
//calling eval()
(function(definition, current , answer, mi) {
//using type 'Field value duration' to cater for
//scenarios where state could cycle, and we want to create
//a new metric instance each time
//Cancel existing metrics and create a new one
if(current.getValue(definitionField) == sn_hr_core.hr.STATE_AWAITING_ACCEPTANCE){
answer = true; //will end any previous metric instances, and create a new one
return;
}
if(current.getValue(definitionField) == sn_hr_core.hr.STATE_WORK_IN_PROGRESS){
mi.endDuration();
answer = false; //will end any previous metric instances, and not create a new one
return;
}
})(definition, current, answer, mi);