- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2025 01:58 PM - edited 07-02-2025 03:06 PM
Hi everyone,
I'm working on a use case where I need to display the total number of Incidents linked to a Problem record in a custom integer field (u_incident_count).
Here's the Business Rule I wrote (on the Incident table, after insert/update, runs when problem_id changes):
It doesn't calculate the actual total number of incidents currently associated with the problem.
What I need instead is:
Every time an incident is linked or unlinked, the problem’s u_incident_count should reflect the total number of incidents currently linked.
Is there a better approach to achieve this? Any suggestions or best practices are appreciated!
Thanks in advance,
Sidhz
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2025 03:26 PM - edited 07-02-2025 03:30 PM
Olá @schetry,
First of all, GlideRecord is great when you need to retrieve details or update the record, but if you are just good with a number of records, then you should go via GlideAggregate, it is better in many aspects.
For example here:
https://www.servicenow.com/community/developer-articles/difference-between-gliderecord-and-glideaggr...
Secondly, why did you write it in a BR? If you want to know the exact number of records, you could do it via scheduled job (triggered: daily, weekly, monthly, on demand) to get that number.
Business rule has trigger conditions (e.g. incident is closed, or user is deactivated, ...), thus this is not the best idea for counting records...
Or it can be a part of report/dashboard...
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2025 03:26 PM - edited 07-02-2025 03:30 PM
Olá @schetry,
First of all, GlideRecord is great when you need to retrieve details or update the record, but if you are just good with a number of records, then you should go via GlideAggregate, it is better in many aspects.
For example here:
https://www.servicenow.com/community/developer-articles/difference-between-gliderecord-and-glideaggr...
Secondly, why did you write it in a BR? If you want to know the exact number of records, you could do it via scheduled job (triggered: daily, weekly, monthly, on demand) to get that number.
Business rule has trigger conditions (e.g. incident is closed, or user is deactivated, ...), thus this is not the best idea for counting records...
Or it can be a part of report/dashboard...
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */