SysEmail record sysId from email script

ratnaSingh113
Tera Contributor

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.

ratnaSingh113_0-1673611946301.png

 

Instead of Line 8,9 I want to use sysEmail table and record SysId of the mail.

 

2 REPLIES 2

Omkar Kumbhar
Mega Sage
Mega Sage

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/>');
   }
}

If I was able to help you with your case, please click the Thumb Icon and mark as Correct.

ratnaSingh113
Tera Contributor

@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";