How to get number of incident records for a user in User form?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2020 03:22 AM
I would like to display the incidents count by particular user(i.e incidents caller_id=User's sys_id) on the User form. Can anyone help me how to achieve that?
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2020 03:31 AM
Hi Jahnavi,
You can simply create a report as below.
If you still will to have a field created & values populated you can have an Before Insert/Update business rule on incident table with below code.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var getrelatedinci=new GlideRecord('incident');
getrelatedinci.addQuery('caller_id',current.caller_id);
getrelatedinci.query();
while(getrelatedinci.next())
{
current.u_incidentcounts= parseInt(current.u_incidentcounts)+1; //replace incidentcounts with correct field name
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2020 02:21 AM
Hi,
Is there anyway that I can get the Incident number on the report you specified?
Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2020 03:37 AM
Hi,
1. For existing users you need a fix script to update the count of al incidents
2. Then write a BR and update whenever a new incident is created.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2020 03:51 AM
Hi,
I don't want to save this field value in User table. But, I would like the value be populated on User's list view. The field like "Default Value" can be used to write the javascript code there for this column?
Note: I want the count be displayed on Users' form view.