Attachment count!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2011 11:07 AM
Hi on kb_knowledge table i have created a field called attachment counter (this field will be counting the number of attachment to particular article.)
Any idea how to do this.I am thinking of making after isert/update b.Rule.
var att = new GlideRecord("sys_attachment");
att.addQuery("table_name","kb_knowledge");
what else :-)....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2017 02:10 AM
Hi,
My count of attachment is coming as 2383..
Can you please help?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2017 02:35 AM
Hi Prerna,
Can you share your code please.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2017 04:21 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2017 04:27 AM
var x = new GlideRecord('kb_knowledge');
x.addQuery('sys_id', current.table_sys_id);
x.query();
while(x.next())------------------------------------------------------------------- change added here
{
var y = new GlideRecord('sys_attachment');
y.addQuery('table_sys_id',x.sys_id);
y.query();
x.u_attachment_count = y.getRowCount();
x.update();
}
Use while loop above code and check
Please like or Mark correct based on the impact of response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2017 04:36 AM