- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2016 08:27 PM
How does the table kb_knowledge link to sys_attachment. I'm trying to get the sys id of the attachment that is on the kb_knowledge.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2016 10:23 PM
Hi Florence,
Write a business rule on the Knowledge table.
Inside script, write a Glide query to sys_attachment table.Like,
var attachment = new GlideRecord('sys_attachment');
attachment.addQuery('table_sys_id',current.sys_id);
attachment.query();
while(attachment.next()){
gs.addInfoMessage('sys_id of the attachment is : ' +attachment.sys_id);
}
Thanks,
Mihir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2016 10:23 PM
Hi Florence,
Write a business rule on the Knowledge table.
Inside script, write a Glide query to sys_attachment table.Like,
var attachment = new GlideRecord('sys_attachment');
attachment.addQuery('table_sys_id',current.sys_id);
attachment.query();
while(attachment.next()){
gs.addInfoMessage('sys_id of the attachment is : ' +attachment.sys_id);
}
Thanks,
Mihir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2016 06:41 AM
You can also just right click on the attachment and Copy Shortcut (if your browser has that option). The SysID will be in that URL:
xxxxx.service-now.com/sys_attachment.do?sys_id=f20f4fda6f429200e4ec496aea3ee40e
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2016 06:50 AM
In addition to Mihir's and Stephanie's answer, you can add the Attachments Related List to the Form. This is a custom and global relationship that does the hard work of matching up an attachment to your record (have a look in System Definition → Relationships and look for the record with the name of "Attachments").
Plus you can work with the related list as normal (such as right-click on an attachment to get its sys_id) and it's updated immediately as soon as you attach a file to the parent record.
- Shahid
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2016 07:03 AM
Thank you all for your help. It has been very helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2018 01:01 PM
Just wanted to add that having the filename of the attachment associated to the sys_id is helpful as well, so the last line of the code given above by Mihir could be:
gs.addInfoMessage('sys_id of attachment - '+attachment.file_name + ' is : ' +attachment.sys_id);
This way both attributes are displayed, especially helpful when you have multiple attachments to one record. Of course this business rule should only have a Role Condition of admin defined as well.