How to get the attachment count in form?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2018 06:16 AM
2 REPLIES 2

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2018 11:38 AM
I'm not sure what you're trying to do exactly, but if you're trying to get a count of attachments associated to an incident or something this type of script would work in a 'before' business rule.
// Query attachments associated to this record
var att = new GlideRecord('sys_attachment');
att.addQuery('table_sys_id', current.sys_id);
att.query();
current.u_attach_number = att.getRowCount();

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2018 12:06 PM
Hi,
you need to write before(insert & update) BR in Incident table for that.
and in script section use below code.
var gr= new GlideRecord("sys_attachment");
gr.addQuery("table_sys_id",current.sys_id);
gr.query();
current.u_attach_number=gr.getRowCount();
Mark correct or helpful if it helps you.
Warm Regards,
Pranay Tiwari