- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2025 04:17 AM
Metric definition defined but not creating metric instances for sys_updated_by field.
Any suggestion, how to achieve it.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2025 06:16 AM
ServiceNow doesn't monitor OOTB system fields (sys_created_by, sys_updated_by) so metric instances won't trigger unless you add custom logic
use this script in the Metric definition
createMetric(current.sys_updated_by.toString());
function createMetric(value) {
var mi = new MetricInstance(definition, current);
var gr = mi.getNewRecord();
gr.field_value = value;
gr.calculation_complete = true;
gr.insert();
}
then have after update business rule on incident table to trigger metric.update event
this will fire the event every time the record is updated allowing your metric definition to create desired metric instances
(function executeRule(current, previous /*null when async*/) {
gs.eventQueue('metric.update', current, '[sys_updated_by]', 1, 'metric_update');
})(current, previous);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2025 05:31 AM
Hi @Ravi Gupta1
Is this table a task-based table? If not, then metrics will not work.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2025 05:44 AM
Hi Atul,
Table which I am using is task based. I am able to create metric instance for other fields but not for sys field for same table.
Thanks
Ravi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2025 05:50 AM
Thanks @Ravi Gupta1 . Could you please try this in the Incident table as an example? Create a new record, then update it and check if the capture is happening or not.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************