email attchments to incident
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 10:13 PM
Hi
I am trying to attach files through email below code attachments are not working provide any alternate one.
"
"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 10:27 PM
Hi @shivaadapa,
You can use "GlideSysAttachment" in order to copy the attachments -
Here's a sample code -
GlideSysAttachment.copy(sourceTable, sourceSysID,targetTable,targetSysID);
Reference - https://developer.servicenow.com/dev.do#!/reference/api/vancouver/server_legacy/GlideSysAttachmentGl...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 10:51 PM
Hi @shivaadapa
Can you try this-
var incidentGR = new GlideRecord('incident');
incidentGR.initialize();
incidentGR.caller_id = email.from_sys_id;
incidentGR.comments = "Received from: " + email.origemail + "\n\n" + email.body_text;
incidentGR.short_description = email.subject;
incidentGR.category = "inquiry";
incidentGR.incident_state = 1;
incidentGR.notify = 2;
incidentGR.contact_type = "email";
incidentGR.u_most_recent_caller_mail = email.body_html;
var incidentSysId = incidentGR.insert();
if (incidentSysId) {
// Copy attachments from email to the incident record
var attachmentCopied = GlideSysAttachment.copy('sys_email', email.sys_id, 'incident', incidentSysId);
if (attachmentCopied) {
gs.info('Attachments copied successfully.');
} else {
gs.error('Failed to copy attachments.');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2024 12:07 AM
Hi @Amit Pandey
incident is creating but attachments are not adding to the new incdient record. attachments are attaching to the email logs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2024 05:30 AM