Adding attachments to Email

Adityanshu Sing
Tera Contributor

We want to send attachment available in sctask1 through email .The email gets trigger after closure of sctask 6. We wrote the business rule at certain condition but it is not working . can anyone please help me how to get this ?

 

 

 

 

 

 

(function executeRule(current, previous /*null when async*/ ) {

//    var ins = current.instance;
    var at = new GlideRecord("sc_task");
	at.addQuery('short_description', 'STARTSWITH', 'Attach Signed Lease');
	at.query();
	while(at.next()){
		var syid= at.getUniqueValue();
	}
	var gr = new GlideRecord("sc_task");
    var ins = gr.get(current.instance);
    if (ins) {
        var grSysAtt = new GlideRecord('sys_attachment');
        grSysAtt.addQuery("table_sys_id", syid);
        grSysAtt.query();
        while (grSysAtt.next()) {
            var content = new GlideSysAttachment().getContentStream(ins.sys_id);
            new GlideSysAttachment().writeContentStream(current, grSysAtt.getValue('file_name'), grSysAtt.getValue('content_type'), content);
        }
    }

})(current, previous);

 

 

Capture21.PNG

 

 

5 REPLIES 5

VenkataSivK
Tera Contributor

Thanks a lot