closing all the metric records
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi Team,
I am having a requirement in the CSM module.
I want to capture all the Metric instances when the case state changed from Active to False. So, I have created a Async BR with all the Metric Definitions stored in the property. It is updating all the records sometimes and leaving few records in the very next attempt. The BR wasn't able to update all Metric Instances and leaving the very recently created when the state changes to active to false. I tried Script Include calling from the BR but failed abruptly. I have tried Scheduled Job which will trigger via After BR and it is working totally fine as expected. But my architect isn't allowing me to go through this approach. I have checked all the OOTB things but no luck. It would be great if there is any other way to proceed further or any enhancements are required to fix this issue. Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @Tanushree Maiti,
Please check my Async Update BR,
(function executeRule(current, previous /*null when async*/ ) {
var metricProperty = gs.getProperty('AllMetricPropertiesWereIncludedHERE').split(',');
var grstateMetrics = new GlideRecord('metric_instance');
grstateMetrics.addQuery('id', current.sys_id);
//grstateMetrics.addQuery('calculation_complete',false);
grstateMetrics.addQuery('definition', 'IN', metricProperty);
grstateMetrics.query();
while (grstateMetrics.next()) {
if (grstateMetrics.calculation_complete == false) {
gs.sleep(10000);
var startTime = grstateMetrics.start.getValue();
var endTime = current.getValue('closed_at') || current.getValue('sys_updated_on') || new GlideDateTime().getValue();
grstateMetrics.end = endTime;
grstateMetrics.duration = gs.dateDiff(startTime, endTime, false);
grstateMetrics.calculation_complete = true;
grstateMetrics.update();
}
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
@Imran4 Certainly! Using Flow Designer in ServiceNow is a great way to handle your requirement for updating Metric instances when the Case state changes from Active to False.
