add attachments to the table through email
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-14-2024 11:37 PM
Hi
How to attach any files to the incident record through inbound email action.
In the instance there is a OOTB create incident inbound email action but there is no any attachment related code over there.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-15-2024 03:08 AM
You'll need to modify the script to handle attachments. Here's a basic outline of what you'll need to do:
- Parse the email message to extract attachments.
- Create records in the appropriate attachment table (such as sys_attachment).
- Associate the attachments with the newly created incident record.
Example Code: Below is a simplified example of how you might modify the script to handle attachments. This example assumes that the attachments are included as part of the email body
// Extract attachments from email
var attachments = email.getAttachments();
// Iterate over attachments
for (var i = 0; i < attachments.size(); i++) {
var attachment = attachments.get(i);
// Create attachment record
var attachmentRecord = new GlideRecord('sys_attachment');
attachmentRecord.initialize();
attachmentRecord.table_name = 'incident';
attachmentRecord.file_name = attachment.getName();
attachmentRecord.content_type = attachment.getContentType();
attachmentRecord.file_size = attachment.getSize();
attachmentRecord.sys_created_by = gs.getUserID(); // Set the creator as needed
attachmentRecord.insert();
// Associate attachment with incident record
var incidentAttachment = new GlideSysAttachment();
incidentAttachment.write(incidentSysID, attachmentRecord.getUniqueValue());
}
Please Mark ā Correct if this solves your query and also mark šHelpful if you find my response worthy based on the impact.
Thanks