- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2022 09:59 PM
How to bring the age of oldest ticket created in the list of child task (x_sts_claims) to one of the fields[Age of Oldest open child ticket ] in Parent Table(x_sts_mains) . Any help would be appreciated .
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2022 12:35 AM
Hi,
keep BR on parent table
Display
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord("x_sts_claims");
gr.addQuery('status','open'); // give correct field name and value to check
gr.orderBy('sys_created_on');
gr.addQuery("parent",current.getUniqueValue()); // give correct parent field
gr.setLimit(1);
gr.query();
if (gr.next()) {
var nowTime = new GlideDateTime();
var childTime = new GlideDateTime(gr.sys_created_on);
var dur = GlideDateTime.subtract(childTime, nowTime);
var days = parseInt(dur.getNumericValue()/86400000);
current.fieldName = days; // give correct field name here
}
})(current, previous);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2022 10:20 PM
Hi,
Can you please share how these two tables are related and what is the criteria for Oldest open ticket?
And when you want to populate that information?
Thanks,
Anil Lande
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2022 10:28 PM
Its a scoped application , where x_sts_mains is the parent table and x_sts_claims is the child table .
Parent table can have multiple child claims ticket...so i want to find out the age of the oldest Open claim ticket's age in days and display it on the field i.e Oldest open child ticket which is present on parent form.
Want to show on dispalying the form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2022 11:23 PM
Hi,
how are you determining the age of ticket?
are you tracking it based on closed - opened on child record?
what script did you start?
when should the field on parent get updated
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2022 11:38 PM
how are you determining the age of ticket? by 'sys_created_on'
are you tracking it based on closed - opened on child record? Only for Open child tickets.
when should the field on parent get updated - the field Age of Oldest open child ticket (in days) should display on the parent form with the days count once the user open the form.