How do we add a specific attachment to a notification via event queue?

sunilhp
Tera Contributor

I have a requirement to generate an Email Notification via an event queue. in my case the incident contains two attachments but I need to pass only one attachment to the gs.eventqueue method. Can someone tell me if there is a way to achieve this? the following code is inserting all the attachments in the incident but I want only one attachment. any help would be appreciated!

gs.eventqueue('event record', incObj, RECIPIENTS.toString());

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

No direct way.

If you use the Include attachment checkbox it would pick all the files and include in outbound email

Solution/Workaround:

1) create an after update BR on sys_email with proper condition such as it should run only for your notification subject and table

2) in the script you can query sys_attachment and create a record into sys_email_attachment for that specific attachment

I had used something similar in the past and it had worked

Regards
Ankur

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

@sunilhp 

Thank you for marking my response as helpful.

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

Regards
Ankur

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

@sunilhp 

Thank you for marking my response as helpful.

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

Regards
Ankur

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

@sunilhp 

Thank you for marking my response as helpful.

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

Regards
Ankur

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