Attachment Count in Change Request table for Reports
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 06:26 AM
Hi,
We are creating a Report on the Change Request table and would like to display the number/count of attachments attached to each change record.
Can someone please assist me with this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 06:32 AM
You need to create a field displaying count of attachment and to update that field you need to write the logic using business rule
Check with your customer if they are ok to have a new field on form
If my answer solved your issue, please mark my answer as ✅Correct & 👍Helpful based on the Impact
Thanks,
Manjusha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 06:55 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2023 07:33 AM - edited 09-01-2023 07:34 AM
Use below code to update count field on change form(count field you need to create on the form )
var grAtt= new GlideAggregate('sys_attachment');
var count ='';
grAtt.addQuery('table_name','change_request');
grAtt.addQuery('table_sys_id',current.sys_id);
grAtt.addAggregate('COUNT');
grAtt.query();
while(grAtt.next()){
count =grAtt.getAggregate('COUNT');
}
current.attachmentCount = count;// replace AttachmentCount with the count field name which you created on your change form
If my answer solved your issue, please mark my answer as ✅Correct & 👍Helpful based on the Impact
Thanks,
Manjusha Bangale
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 06:39 AM
Hey @Hari S1 :
You could report on the sys_attachment table, however, it is not permitted OOB. If you wish to report on the Attachments table, you must add the sys_attachment table to the permitted tables property [glide.ui.permitted_tables].
The best approach is to have a custom field option as a counter on the table and BR on the attachment table to run on insert or delete to update the counter
Mark this as Helpful / Accept the Solution if this clears your issue