last attachment in notification

Vedavalli
Tera Expert

Hi

Is there any option to send the last attachment from multiple attachments in the email notification?

Thank you.

1 ACCEPTED SOLUTION

@Vedavalli 

you can use email script but it will only include link to the latest attachment and not the actual file.

if you want to include file in outbound email then link I shared should work

If you want to include link to the latest attachment added to record then use email script

(function runMailScript(current, template, email, email_action, event) {

    // Add your code here
    template.print('Latest attachment link <br/>');
    var gr = new GlideRecord("sys_attachment");
    gr.orderByDesc('sys_created_on');
    gr.addQuery("table_sys_id", current.sys_id);
    gr.setLimit(1);
    gr.query();
    if (gr.next()) {
        var instance_name = gs.getProperty('glide.servlet.uri');
        template.print('Click <a href="' + instance_name + 'sys_attachment' + '.do?sys_id="' + gr.sys_id + '">' + gr.file_name + '</a> to view the Attachment.');
    }

})(current, template, email, email_action, event);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

8 REPLIES 8

@Ankur Bawiskar 
no it's not fetching the latest attachment.
is there any other way

@Vedavalli 

what script you are using? email script to show link or business rule to add the actual file

what debugging did you do?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

business rule
i've checked with info msgs

@Vedavalli 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader