SysEmail record sysId from email script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2023 03:13 AM - edited 01-13-2023 04:12 AM
Hello All,
I'm currently working on a scenario where I need to generate a PDF file from a string and send it as an attachment to an email.
I can create a PDF component, but I can't add that to an email record.
I tried using sys email.sysId, email.sysId, etc. but was unable to obtain the email record's system ID.
sharing screenshots; kindly assist.
Instead of Line 8,9 I want to use sysEmail table and record SysId of the mail.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2023 03:29 AM
Hello @ratnaSingh113 ,
As the pdf is getting generated can you check if this pdf is stored in sys_attachment table. Next you can glide to attachment table and send an attachment in a form of link.
attachLinks();
function attachLinks() {
//Check for any attachments and add attachment links if they exist
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id',current.sys_id);
gr.query();
if(gr.hasNext()){
template.print('Attachments: \n');
while (gr.next()) {
var attachLink = '<a href="' + gs.getProperty("glide.servlet.uri") + gs.generateURL(gr.getTableName(),gr.sys_id) + '">' + gr.file_name + '</a>';
template.print(attachLink + '\n');
}
template.print('<hr/>');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2023 03:39 AM - edited 01-13-2023 04:29 AM
@Omkar Kumbhar Thanks for the quick response , but at the moment it is being stored in the 'sys_attachment' table but The bare minimum I need is a create PDF that I can email as attachment. Currently just to test PDF part, I'm using traget table as
var targetTable="sysevent_email_action";