- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
We have activated Interaction to our SN instance. However, when user send an email with attachment. Upon checking to the created interaction, there is no file in the Attachment Contextual Side Panel.
Inbound action script:
(function() {
var gr = new GlideRecord('interaction');
gr.initialize();
// Set interaction type = Email
gr.type = 'email';
// Short Description from the email subject
gr.short_description = email.subject ? email.subject.toString() : 'No Subject';
// Default state to 'New'
gr.state = 'new';
// Look up user in sys_user table by email address
var userGR = new GlideRecord('sys_user');
userGR.addQuery('email', email.from);
userGR.query();
if (userGR.next()) {
// Opened for = matched user
gr.opened_for = userGR.sys_id;
// Location = user's location
if (userGR.location)
gr.location = userGR.location;
}
// Build additional comments (no CC)
var comments = [];
comments.push("Subject: " + (email.subject || ""));
comments.push("Body: " + (email.body_text || ""));
comments.push("Recipient Info: " + (email.to || ""));
// Save into Additional Comments (journal field)
gr.u_additional_comments_customer_visible = comments.join("\n");
// Insert the new Interaction
gr.insert();
})();
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
so the incoming email has attachment but it's not getting attached to newly created interaction?
if yes then add this line and see
// Insert the new Interaction
gr.insert();
// copy file
new GlideSysAttachment().copy('sys_email', sys_email.sys_id, 'interaction', gr.getUniqueValue());
💡 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
so the incoming email has attachment but it's not getting attached to newly created interaction?
if yes then add this line and see
// Insert the new Interaction
gr.insert();
// copy file
new GlideSysAttachment().copy('sys_email', sys_email.sys_id, 'interaction', gr.getUniqueValue());
💡 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
Thanks, it worked.
