Send email with only newly added attachment for Network assignment group incidents
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi Team,
I have a requirement to send an email notification when a new attachment is added to an Incident, but only for incidents assigned to the Network assignment group.
The email must include only the newly added attachment.
Previously attached / older attachments should NOT be included in the email.
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Olá @GaneshErike ,
Sim, a orientação do @Ankur Bawiskar é perfeita! A abordagem dele de usar o script de Condição Avançada dentro da Notificação é mais elegante do que criar um Evento separado.
No entanto, em relação ao seu problema com o anexo aparecendo como sys_attachmentmetadados de tabela em vez do arquivo propriamente dito:
O motivo técnico: a caixa de seleção "Incluir anexos" tenta encontrar arquivos anexados ao registro de destino. Como o registro de destino É o anexo ( sys_attachment), ela não consegue encontrar o conteúdo do arquivo porque um arquivo não pode ser anexado a si mesmo dessa maneira.
A solução (o código para corrigir o anexo): Você pode usar a lógica de filtro do @Ankur Bawiskar , mas para anexar o arquivo ao e-mail, você precisa de uma regra de negócios na tabela de e-mail .
Crie esta regra de negócio:
Tabela: E-mail [ sys_email]
Quando: Antes de (Inserir)
Condição: A tabela alvo Ésys_attachment
Roteiro:
(function executeRule(current, previous /*null when async*/) { // This creates the bridge between the Email and the Physical File var grEmailAtt = new GlideRecord('sys_email_attachment'); grEmailAtt.initialize(); grEmailAtt.email = current.sys_id; grEmailAtt.attachment = current.instance; // 'instance' holds the SysID of the attachment record grEmailAtt.insert(); })(current, previous);
Resumo:
Utilize o script do Ankur para a Condição de Notificação (para filtrar por grupo de Rede).
Utilize esta regra de negócio para forçar o arquivo a ser anexado corretamente ao e-mail de saída.
Se essa solução combinada funcionar para você, marque a resposta do Ankur e a minha como Útil/Aceita.
Atenciosamente,
Brandão.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Things to do
-> create notification on sys_attachment table with Insert checkbox and use advanced notification condition to check the INC group and then only send by setting answer=true/false
answer = false;
var incRec = new GlideRecord('incident');
if (incRec.get(current.table_sys_id)) {
if (incRec.assignment_group.getDisplayValue() == 'Network Support') {
answer = true;
}
}
-> then use this link below where I shared approach to include latest attachment in the email
Adding latest attachment from sys_attachment table to sys_email record
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hope you are doing good.
Did my reply answer your question?
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Ganesh, standard notifications include all attachments. To send only the new one, create an async business rule on sys_attachment for Network incidents, trigger a custom event, and use a mail script in the notification to include just the new file. Multiple uploads will trigger multiple emails.

