I want to include attachment attached in Request form in notifications.

Taaha M
Tera Contributor

I am sending a notification for user once request raised is approved.

The notification body should also include attachment attached.

I checked the 'include attachment' checkbox available in notification but it is not working.

How can I get this in notification.

5 REPLIES 5

Rajesh Chopade1
Mega Sage

Hi @Taaha M 

 

You can check following points first to trouble shoot your issue:

Make sure that the user receiving the notification has permission to view the attachments. If the user doesn’t have access, the attachments won’t appear.

 

If you're using a custom email template, ensure that the template supports attachments. You might need to modify the template to accommodate them.

 

If the standard method isn’t working, you can use a script to manually include attachments in the notification.

 

Look at the notification logs to see if there are any errors or warnings that could provide insights.

 

i hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.

thank you

rajesh

 

 

Agreed.
The user receiving the notifications doesn't have access to download links, so I am trying to have an attachment instead where the user can see the attachment in the notification.

I tried using GlideSysAttachment methods....nothing worked.
Can you suggest what logical is to be used.

hi @Taaha M 

you can use a script to manually include attachments in the notification.

// Function to attach files from the record to the email as inline
function attachInlineFiles(current, email) {
    var attachment = new GlideSysAttachment();
    var attachments = attachment.getAttachments(current.sys_id);
    while (attachments.next()) {
        var fileName = attachments.file_name;
        var sysId = attachments.sys_id;

        // Get the attachment content
        var content = attachment.getContent(sysId);
        var base64Content = GlideStringUtil.base64Encode(content);
        
        // Define the content type (change based on your attachment type)
        var contentType = attachments.content_type || 'application/octet-stream';
        
        // Create a content ID for referencing in the email body
        var contentId = "attachment_" + sysId;

        // Add the attachment as inline
        email.addInlineAttachment(contentId, base64Content, contentType, fileName);

        // Add a reference to the attachment in the email body
        email.body += '<br><img src="cid:' + contentId + '" alt="' + fileName + '" />';
    }
}

// Call the function to attach files
attachInlineFiles(current, email);

 

 

 

i hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.

thank you

rajesh

Where are you create this script? It's a script include?