Check if an attachment is added in current update of record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2014 10:54 PM
Hi
I need to check if an attachment has been updated to the record. on the basis of that i need to Run some function.
Can this be possible?
The skeleton can be like this:
if(an attacment added){ yes(); else No();
I thought of a soultion to write an After "Insert " business rule on "sys_attachment" table, to check if an attachment is added for the current change reuqest.
But dont know how to proceed.
Any ideas???
Regards
Deepak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2014 01:30 AM
Hi Deepak,
There is a function called hasAttachments() that checks if the current Record has attachments or not.
Or you can query the sys_attachment table with the current Updated record if the Count changes or not.
Thanks,
Subhajit

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2014 01:54 AM
Hi Deepak,
Please refer section 8.16 in below wiki link for more info
http://wiki.servicenow.com/index.php?title=GlideRecord
Script:
var inc = new GlideRecord("sys_attachment");
inc.addQuery("table_name", "incident");
inc.addQuery("sys_created_on", '>=', 'javascript:gs.minutesAgo(15)');//check if user has added attachment in last 15minutes
inc.query();
while(inc.next())
{
}
Thanks,
Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2014 11:35 PM
Hi Deepak ,
You can use use hasAttachment method to check whether current record carrying any attachment or not in your IF condition .
or you can use glide in your BR
var attachments = new GlideRecord('sys_attachment');
attachments.addQuery('table_sys_id',current.sys_id);
attachments.query();
var rowCount = attachments.getRowCount();
and use rowCount in your If condition . if its more then 0 then it will help you to apply conditions according to your requirement.
Thanks ,
Rohit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2018 07:45 PM
Hi how to check Row Count is getting changed or not. Please help even i have same kind of requirement.