- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2022 08:20 PM
Hi,
I have a requirement when inbound email received from service-now with the subject line with RITM numbr, it should create a new record in the table 'department' and that record should have that inbound email as an attachment.
This should be applied to New, reply , and forward emails.
So, when writing an inbound email action to reply , Inbound email action's target table should be sc_req_item table.
But the issue is now, this attachment not getting inserted into record created in 'department' table. Please help me to resolve this issue. Any help is very much appreciated!.
(function runAction( /*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
//Add email as an attachment to the record
var attachment = new GlideSysAttachment();
fileName = email.subject + '.eml';
contentType = 'application/octet-stream';
content = email.content_type + "\n" + email.headers + "\n\n\n\n" + email.body_text;
attachment.write(dept_gr, fileName, contentType, content);
dept_gr.insert();
}
})(current, event, email, logger, classifier);
This doesn't insert the attachment. Please help me to resolve this issue
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2022 05:29 AM
Hi,
I would propose to change the order:
dept_gr.insert();
attachment.write(dept_gr, fileName, contentType, content);
Best Regards,
Marcin
If my answer helped you in any way, please mark this answer as helpful and correct.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2022 05:29 AM
Hi,
I would propose to change the order:
dept_gr.insert();
attachment.write(dept_gr, fileName, contentType, content);
Best Regards,
Marcin
If my answer helped you in any way, please mark this answer as helpful and correct.