Does the metric has a valid until date to stop the metric from being ongoing and executing?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2025 06:00 PM
Dear experts,
I would like to ask about the metrics, I dont see a valid until date for the metric nor the metric definition. Does ServiceNOW have this kind of feature for metrics? To set the availability and the validity for the metrics. Waiting for your reply, thank you.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2025 06:04 PM
Hi.
Could you perhaps explain why a metric would need a validity ? The answer to your question is no, but I'd like to understand why you're looking for validity and then offer a more appropriate solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2025 11:39 PM
Hi,
There is no valid unto date, however there is an 'Active' field on the metric (and the metric definition). It will not execute once the Active is false. If you set the Active flag on the Metric definition as false, then all the metrics' on the metric definition's Active flag will be set as false.
Thanks,
Vaisakh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2025 08:02 PM
Hi Vaisakh,
Thanks for the reply, but I have created a scheduled job run that runs daily and this is my script but I think it is still not functioning. May I get some help or advise for my script? Thank you.
(function executeRule(current, gsr) {
var today = new GlideDate();
today.setDisplayValue(gs.nowDate()); // 'yyyy-MM-dd' format
var mdGR = new GlideRecord('sn_grc_metric_definition'); // Replace if using a different table
mdGR.addQuery('u_valid_until', '<=', today); // Compare u_valid_until <= today
mdGR.addQuery('active', true); // Only process active records
mdGR.query();
while (mdGR.next()) {
mdGR.setValue('active', false);
mdGR.update();
gs.info('Deactivated Metric Definition: ' + mdGR.getDisplayValue('name') + ' due to expired valid_until date.');
}
})(current, gsr);