Get row count of related records
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2020 04:30 AM
Hi All,
I have a field on the form as test. i want to populate this field on the basis of a related list, so i have a related list of business service which shows the records from cbdb_ci_service tables.i want to count of services related to that particular task and update that field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2020 05:23 AM
Hi Priya,
So since you want field to be updated based on service is added/updated or deleted then BR should be on cmdb_ci_service table
There must be some field on cmdb_ci_service which holds certificate information
query with that field and then get the count
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
08-14-2020 05:26 AM
Hi,
so in cmdb_ci_service table.. the certification is the related list. so we query same way like we query a table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2020 05:41 AM
Hi Priya,
Hope you are doing good.
Let me know if that answered your question.
If so, please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.
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
08-23-2020 04:37 AM
Hi Priya,
Hope you are doing good.
Let me know if that answered your question.
If so, please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.
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
08-14-2020 04:56 AM
Have the field as a calculated field maybe? and query your respective table and get the rowcount.
var categoryCount = 0;
var gr = new GlideAggregate('your table');
gr.addQuery(your query);
gr.addAggregate("COUNT");
gr.query();
while(gr.next()) {
categoryCount = gr.getAggregate("COUNT");
}
return categoryCount;
Please Mark as ✅ Correct if this solves your issue and also mark ???? Helpful if it helps resolve your problem.
Thanks,
Saji