- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2014 10:03 AM
Hi,
I have an inbound action that creates RITM thru CART API.
Everything is working fine, RITM is created but attachments are not included on the RITM ticket.
I might be missing something on my inbound action... any advices?
createRequest();
function createRequest() {
var cart = new Cart();
// add in cart
var item = cart.addItem('62d832d56f8721006e3f4425eb3ee4b4');
cart.setVariable(item, 'cleanupgensubject', email.subject.toString());
cart.setVariable(item, 'cleanUpgenDetails', email.body_html);
var cartmsg = "received from: " + email.origemail + "\n\n" + email.body_text;
var rc = cart.placeOrder();
}
Thank you very much.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2014 09:24 AM
Hi Azenith,
You need to add the below code after placing the order in the cart:
var ritmSysID = "";
var ritmRec = new GlideRecord("sc_req_item");
ritmRec.addQuery("request", rc.sys_id);
ritmRec.query();
if(ritmRec.next()){
ritmSysID = ritmRec.sys_id;
}
Thanks,
CK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2014 12:16 AM
Hi Azenith,
Try adding the below script to your Inbound action and then it should create attachments to your RITM ticket:
var emailRec = new GlideRecord("sys_email");
emailRec.addQuery("uid", email.uid);
emailRec.orderByDesc("sys_created_on")
emailRec.query();
if(emailRec.next()){
Packages.com.glide.ui.SysAttachment("sys_email", emailRec.sys_id, "sc_req_item", <ritm_sys_id>);
}
Thanks,
CK

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2014 07:56 AM
You can do something like what CK suggests.
In an inbound email, ServiceNow automatically copies the attachments to the sys_email record, so you can use the following article combined with CK's script to copy the attachment to the RITM record. Since the catalog api only gives you the REQ id, you will need to use that to query to the item id in order to copy the attachment.
Copy Attachments from Record to Record - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2014 08:43 AM
Thanks Brad and CK. Having some difficulties though on getting the sys id of the RITM created from the inbound action..can you kindly provide some more information on how to achieve this? thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2014 09:24 AM
Hi Azenith,
You need to add the below code after placing the order in the cart:
var ritmSysID = "";
var ritmRec = new GlideRecord("sc_req_item");
ritmRec.addQuery("request", rc.sys_id);
ritmRec.query();
if(ritmRec.next()){
ritmSysID = ritmRec.sys_id;
}
Thanks,
CK