Adding inbound email attachment to the RITM it creates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2023 12:54 PM
I have an Inbound Action that creates an REQ/RITM. The script is below. If the inbound email has an attachment, I want that attachment to be attached to the RITM. This seems to happen automatically for inbound emails that create incidents. If I look at the email logs of the email that created the REQ/RITM, it’s logging the attachment but no action is being taken, unlike when the inbound email creates an incident, the action says Attached to Target Record. I did change the glide.email.inbound.image_sys_attachment.filter.action system property from AttachEmail to AttachTarget, but that did not work. Any help would be appreciated!
createRequest();
function createRequest() {
var cart = new Cart();
// Add in cart, sys_id for catalog item
var item = cart.addItem('d9a69b671b1b611092beea40604bcbda');
// add cart message to commments
var cartmsg = "received from: " + email.origemail + "\n\n" + email.body_text;
cart.setVariable(item,'short_description', "MDF door access audit");
// Places order and creates request
var rc = cart.placeOrder();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2023 01:42 PM
Hi, if you want to keep thing simple and use OOB attachment functionality then I suspect you need to follow the OOB process to create the task involved (take a look at incident creation inbound action) and this should enable the OOB attachment functionality.
Otherwise, if you are going to create all of your tasks using script within the inbound action then this post appears to have a solution for you.
Solved: Attachment on Inbound Actions - CART API - ServiceNow Community
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2023 05:55 AM
Hi Tony,
Thank you for you reply. I'm all for simplicity. I've looked at our "Create Incident" Inbound Action script but have been unable to determine how the attachment is making it to the created incident. Below is the top and bottom sections of the Create Incident script, minus a large chunk of the middle that is just iterations of "else if" statements looking at From, Subject and Body content and applying incident templates to use. Maybe I'm missing the obvious, but where in this script is it copying the email attachment to the incident?
current.comments = "received from: " + email.origemail + "\n\n" + email.body_text;
current.short_description = email.subject;
current.description = email.body_text;
var sid = "";
var usr = new GlideRecord('sys_user');
usr.addQuery('email', email.origemail);
usr.query();
if (usr.next()) {
sid = usr.sys_id;
}
var emailFrom = email.from.toLowerCase();
var emailSubject = email.subject.toLowerCase();
var emailBody = email.body_text.toLowerCase();
var emailTo = email.to.toLowerCase();
(lots of middle code removed for simplicity)
else {
current.assignment_group = '02256ddaeda8f0002f5e466ea6dc5ad7';
current.impact = 3;
current.urgency = 2;
}
current.u_customer = sid;
current.opened_by = sid;
//current.incident_state = 1;
current.notify = 2;
//current.contact_type = "Alert";
if (email.body.assign != undefined){
current.assigned_to = email.body.assign;
}
if(email.importance != undefined){
if (email.importance == "High"){
current.priority = 1;
}
}
if (email.body.priority != undefined){
current.priority = email.body.priority;
}
current.insert();