- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 01:35 PM
Hello,
I am creating an incident from an email via an inbound action. I want to attach a copy of the email to the incident. Below is the code I have been trying to get to copy the email as an attachment but not successful with. Can anyone help me with this issue?
var attachment = new GlideSysAttachment();
var st = attachment.copy('sys_email', sys_email.sys_id,'incident', current.sys_id);
gs.log('@JW Attachment Copied: ' + st + ' | SysEmail: ' + sys_email.sys_id);
//Log Output
//@JW Attachment Copied: [] | SysEmail: 21a76aae87a24a90cde8fc88cebb351c | CurrentSys: b6881c8387a2ca90cde8fc88cebb350d
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 07:51 PM
Hi, I would try wrapping your message in [code][/code] tags and using email.body_html
Render journal field entries as HTML (servicenow.com)
Formatting within Journal fields using HTML & [cod... - ServiceNow Community
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 02:20 PM
Hi, the email you see in ServiceNow is a record in sys_email table, it is not an attachment.
Can you clarify the business driver\requirement for this, as representation of the email should already be available directly from the activity formatter of the record/task it is related to; and I doubt recreating the email message (so you could attach it) would result in something that was considered to be the actual 'received' email.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 02:30 PM
Thanks for the response, that makes sense.
The main motivator behind this is when we just copy the email body into the comments section of the incident all the HTML formatting from the email is lost and its very hard for agents to read. If there is a way to copy the contents of the email to the incident and it keeps the formatting/HTML that would work for us. Here is how we have been copying the email body
current.comments = "received from: " + email.origemail + "\n\n" + email.body_text;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 07:51 PM
Hi, I would try wrapping your message in [code][/code] tags and using email.body_html
Render journal field entries as HTML (servicenow.com)
Formatting within Journal fields using HTML & [cod... - ServiceNow Community
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 08:07 AM
This solved my issue! Thank you very much. Appreciate you showing me a different way to solve the issue I had.