- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2025 08:50 AM
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
I want to be able to show the related metrics on a relationship tab on the bottom of the task form.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2025 09:15 AM
Hi @Scott29 ,
To create a related list showing all metrics related to the sc_task record you can do the following.
- Create a new Custom Relationship. System Definition->Relationships (Table Name: sys_relationship)
- Applies to -> sc_task (since you want to show related list on SC Task form)
- Query from -> Metric Table
- 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:
If my response helped, please mark it helpful and accept the solution so that it benefits future readers.
Regards,
Rohit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2025 09:20 AM
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)
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2025 08:59 AM
Hi @Scott29
Metrics are used to track the previous state or assignment group of a record. I'm not sure what your exact requirement is regarding the 1-to-M relationship."
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
03-04-2025 09:15 AM
Hi @Scott29 ,
To create a related list showing all metrics related to the sc_task record you can do the following.
- Create a new Custom Relationship. System Definition->Relationships (Table Name: sys_relationship)
- Applies to -> sc_task (since you want to show related list on SC Task form)
- Query from -> Metric Table
- 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:
If my response helped, please mark it helpful and accept the solution so that it benefits future readers.
Regards,
Rohit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2025 09:20 AM
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)
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2025 11:22 AM
Thanks, you are correct. I checked for the relationship before I built the metric.