how to attach Catalog Item attachments to Workflow Notification activity using Email Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2023 11:45 AM
how to attach Catalog Item attachments to Workflow Notification activity using Email Script.
The following code in the Email Script is not working. There is no attachment in the attachments tab of the email.
---------------------------------------------------------------------------------------------------------------------------------------

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2023 12:14 PM
@KeDix When a user uploads an attachment on a catalog item, initially the table name for that attachment gets recorded as 'sc_cart_item'. However, once the submit button on catalog item is pressed a request gets created and the same attachment gets transferred to the request and the table name and sys_id fields of the attachment are updated accordingly.
In your case, I am assuming the request has already been created, hence you should use attachmentGR.addQuery('table_name', 'sc_req_item');
Also, for the testing purposes, just comment the line attachmentGR.addQuery('file_name', current.variables[attachmentVariable].name); and see if the query returns the result.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 04:13 AM
Yes. Submit button is clicked and then I am using Notification Activity in the workflow. This notification activity uses EmaiScript.
I used attachmentGR.addQuery('table_name', 'sc_req_item'); but that did not work previously hence I changed the table name to 'ZZ_YYsc_cart_item' by looking at the attachment table.
I have now changed the table name to as you have suggested and commented code too. But I could not see the attachment after opening the email record.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 05:20 AM
@KeDix After creating the request, I suggest you to run the following script in Background Script console and check the result printed by the script.
var attachmentGR = new GlideRecord('sys_attachment');
attachmentGR.addQuery('table_name', 'sc_req_item');
attachmentGR.addQuery('table_sys_id', current.sys_id); //replace the sys_id with the sys_id of the request
// attachmentGR.addQuery('file_name', current.variables[attachmentVariable].name);
attachmentGR.query();
if (attachmentGR.next()) {
//email.addAttachment(attachmentGR); // Attach the file
gs.info('This is sys_id of the attachment '+attachmentGR.getValue('sys_id'));
}
In the above script, simply replace the current.sys_id with the sys_id of the request and run the script to check if the log gets printed.