- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2022 07:45 AM
Hi, i am having an issue with my script include. in my script include I am creating a csv file to save to the "sys_attachment" table. to do this I have created this code
// create file and save
var grRec = new GlideRecord("sys_attachment");
grRec.addQuery('table_sys_id',current.sys_id);
grRec.initialize();
var grAttachment = new GlideSysAttachment();
attachmentId = grAttachment.write(grRec, fileName, 'application/csv',csvContent);
my issue is, how can i get the sys_id or the "table_sys_id" from my attachment in the script?since i am making a link to the attachment to download it.
Solved! Go to Solution.
- Labels:
-
Agent Workspace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2022 07:50 AM
Hi,
write() method requires 1st parameter as the GlideRecord object of the record where you wish to attach the file.
Example: you can query incident table with some incident number and pass the object as 1st parameter
check the docs
Your attachmentId variable will hold the sysId of the sys_attachment record
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2022 07:50 AM
Hi,
write() method requires 1st parameter as the GlideRecord object of the record where you wish to attach the file.
Example: you can query incident table with some incident number and pass the object as 1st parameter
check the docs
Your attachmentId variable will hold the sysId of the sys_attachment record
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader