- 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
02-23-2015 08:14 AM
oopsy .. missed the copy statement..
GlideSysAttachment.copy("sys_email", emailRec.sys_id, "sc_req_item", ritmRec.sys_id);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2020 10:59 PM
Still tried the script with copy statement its not working

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2023 09:49 AM
/* INBOUND EMAIL ACTION WITH CART API and INCLUDE ATTACHMENT */
(function runAction( /*GlideRecord*/ current, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
createRequest();
function createRequest() {
var cart = new Cart();
var item = cart.addItem('9fd4dc2b1bca6190856aed35604bcb19'); //Generic Request Catalog Item(should be in sys property)
cart.setVariable(item, 'requested_for', 'f9115b3c1ba7111026be8485624bcb11'); //Workday User (should be in sys property)
cart.setVariable(item, 'short_description', email.subject);
cart.setVariable(item, 'description', "PLEASE NOTE: " + email.body_text);
var rc = cart.placeOrder();
updateRITM(rc.sys_id);
}
function updateRITM(req) {
var ritmSysID = "";
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('request', req); //req is what we passed from the previous function. the sys_id of the request.
ritm.query();
while (ritm.next()) {
ritm.priority = email.body.priority; //good example of how to exploit email body variables
ritm.work_notes = email.body_text;
ritmSysID = ritm.getUniqueValue();
ritm.update();
attachIT(ritmSysID);
}
}
function attachIT(thisSysID) {
var emailRec = new GlideRecord("sys_email");
emailRec.addQuery("uid", email.uid);
emailRec.orderByDesc("sys_created_on")
emailRec.query();
if (emailRec.next()) {
emailRec.instance = thisSysID;
emailRec.target_table = "sc_req_item";
emailRec.update();
GlideSysAttachment.copy('sys_email', emailRec.sys_id, 'sc_req_item', thisSysID);
}
}
})(current, email, logger, classifier);