ServiceNow Metrics relationship between sc_task and metric_instance

Scott29
Kilo Sage

I created new metric definitions for the sc_task table. I have never created a relationship between tables before. How can I make a 1-to-many relationship between sc_task and metric_instance? Only the metrics that relate to that task and the task ID are in the metric

 

Scott29_0-1741106865106.png

 

I want to be able to show the related metrics on a relationship tab on the bottom of the task form. 

 

2 ACCEPTED SOLUTIONS

Rohit  Singh
Mega Sage

Hi @Scott29 ,

 

To create a related list showing all metrics related to the sc_task record you can do the following.

 

  1. Create a new Custom Relationship. System Definition->Relationships (Table Name: sys_relationship)
  2. Applies to -> sc_task (since you want to show related list on SC Task form)
  3. Query from -> Metric Table
  4. Use script section to build you query. 

 

(function refineQuery(current, parent) {

	// Add your code here, such as current.addQuery(field, value);

	current.addQuery("id",parent.sys_id);

})(current, parent);

 

  • Now in the SC Task from view use "configure related list" and bring you Custom Relationship in the from using slush bucket.

Refer an example in Incident Form:

 

RohitSingh_0-1741108494301.png

 

RohitSingh_1-1741108535831.png

 

 

 

If my response helped, please mark it helpful and accept the solution so that it benefits future readers.

 

Regards,
Rohit

View solution in original post

Chaitanya ILCR
Kilo Patron

Hi @Scott29 ,

if you have created a metric definition for SC task table

you should be able to see Metrics (just configure the related lists and add metrics)

ChaitanyaILCR_0-1741108799433.png

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

View solution in original post

5 REPLIES 5

AndersBGS
Tera Patron
Tera Patron

Hi @Scott29 ,

 

i don’t quite understand your question due to metric and metric definition is to capture previous state or other field change over time. This is not a relationship between tables - so what if that your looking for and what is the business requirement?

 

If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Best regards
Anders

Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/