Skip to page contentSkip to chat
ServiceNow support
    • Community
      Ask questions, give advice, and connect with fellow ServiceNow professionals.
      Developer
      Build, test, and deploy applications
      Documentation
      Find detailed information about ServiceNow products, apps, features, and releases.
      Impact
      Accelerate ROI and amplify your expertise.
      Learning
      Build skills with instructor-led and online training.
      Partner
      Grow your business with promotions, news, and marketing tools
      ServiceNow
      Learn about ServiceNow products & solutions.
      Store
      Download certified apps and integrations that complement ServiceNow.
      Support
      Manage your instances, access self-help, and get technical support.
Why are my Metric record created and updated by 'system'? - Support and Troubleshooting
  • >
  • Knowledge Base
  • >
  • Support and Troubleshooting (Knowledge Base)
  • >
  • Why are my Metric record created and updated by 'system'?
KB0751436

Why are my Metric record created and updated by 'system'?


3908 Views Last updated : Nov 8, 2024 public Copy Permalink
KB Summary by Now Assist

Issue

Symptoms

When a user makes a change within the system and a metric record is generated the "created by" and "updated by" fields are always "system", not the user who actually made the change

Release

All releases

Cause

On the task table, there is a "metric events" business rule which will create a metric.update event. When the event is processed a metric_instance record is created/updated. The metric is processed by "system" and is the reason you see the created by and updated by displayed with "system". This is expected behavior 

Resolution

If you wish to have the metrics displaying the details of the user who initially performed the action which generates/updates the metric you will need to make modifications to the base system

The "metricinstance" script include is responsible for creating an updating all metrics which are type "field value duration" 

https://<INSTANCE>/nav_to.do?uri=sys_script_include.do?sys_id=44c7c3a40a25810200e0dbdf70ea7f0c 

You would need to amend this OOB (Out of Box) script include to manually set the sys_created_on, sys_created_by,sys_updated_on, sys_updated_by and sys_mod_count fields whilst using the GlideRecord autoSysFields(false) when the metric records are inserted/updated. 

Below is an example of a change you could consider which amends the startDuration and endDuration fuctions which are responsible for performing inserts and updates within the metrc_instance table: 

startDuration: function() { 
var gr = this.getNewRecord(); 
gr.field_value = this.current[this.definition.field]; 
gr.start = current.sys_updated_on; 
gr.sys_created_by = current.sys_updated_by;
gr.sys_updated_on = current.sys_updated_on;
gr.sys_updated_by = current.sys_updated_by;
gr.sys_created_on = current.sys_updated_on;

gr.sys_mod_count = 0; 
gr.autoSysFields(false); 
gr.insert(); 
}, 

endDuration: function() { 
var gr = new GlideRecord('metric_instance'); 
gr.addQuery('definition', this.definition.sys_id); 
gr.addQuery('id', this.current.sys_id); 
gr.addQuery('calculation_complete', false); 
gr.query(); 
if (!gr.next()) 
return; 

gr.end = this.current.sys_updated_on; 
gr.duration = gs.dateDiff(gr.start.getDisplayValue(), gr.end.getDisplayValue()); 
gr.calculation_complete = true; 
gr.sys_updated_on = current.sys_updated_on; 
gr.sys_updated_by = current.sys_updated_by; 

if (gr.sys_created_on != current.sys_updated_on) 
{ 
gr.sys_mod_count = 1; 
} 
gr.autoSysFields(false); 
gr.update(); 
}, 

*Please note this is an example only and you can modify this to meet your specific requirements 

If you do decide to make changes to the base "metricinstance" script include please test thoroughly in a sub-production before implementing in production 

Related Links

Please note metric definitions which are type "script calculation" use the script field within the definition for the logic of how the record is created. You would need to amend the logic here for each script calculation metric definition to manually populate the system fields sys_created_on, sys_created_by,sys_updated_on, sys_updated_by and sys_mod_count


The world works with ServiceNow.

Sign in for more! There's more content available only to authenticated users Sign in for more!
Did this KB article help you?
Did this KB article help you?

How would you rate your Now Support digital experience?

*

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

What can we improve? Please select all that apply.

What are we doing well? Please select all that apply.

Tell us more

*

Do you expect a response from this feedback?

  • Terms and conditions
  • Privacy statement
  • GDPR
  • Cookie policy
  • © 2025 ServiceNow. All rights reserved.