- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2024 03:51 AM
Hi All,
I am trying to add attachment in Inbound action.
When the emails comes first, it creating an incident and adding an attachment from the email.
We have a condition, if there is an existing ticket for the same email, then we just need to update email body in the work notes and add attachment in the existing incident.
As per the below code its checking for the existing ticket, if it is found updating work notes with the email body.
Please let me know if there is any out of the box function to add the attachment in existing ticket .
If not, I need to glide Attachment table and update the table sys ID and table name as per my condition.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2024 04:05 AM
You can use GlideSysAttachment Copy method.
Refer GlideSysAttachment Copy
var mailBody = email.body_text.toString();
var checkINC = new GlideRecord('incident');
checkINC.addEncodedQuery('incident_stateNOT IN6,7');
checkINC.addQuery('u_deduplication_key', email.subject);
checkINC.query();
if (checkINC.next()) {
// Existing ticket found, update it
new GlideSysAttachment().copy('sys_email', sys_email.sys_id, 'incident', checkINC.sys_id);
checkINC.work_notes = mailBody;
checkINC.update();
}
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2024 04:05 AM
You can use GlideSysAttachment Copy method.
Refer GlideSysAttachment Copy
var mailBody = email.body_text.toString();
var checkINC = new GlideRecord('incident');
checkINC.addEncodedQuery('incident_stateNOT IN6,7');
checkINC.addQuery('u_deduplication_key', email.subject);
checkINC.query();
if (checkINC.next()) {
// Existing ticket found, update it
new GlideSysAttachment().copy('sys_email', sys_email.sys_id, 'incident', checkINC.sys_id);
checkINC.work_notes = mailBody;
checkINC.update();
}
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2024 04:10 AM