
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2018 02:24 PM
I have an inbound action that is creating an RITM and single catalog tasks. That part is working as expected. however, the attachments are not being copied to the RITM via email. I have tried several of the attempts on the community and its just not copying them over.
I am on Kingston patch 6.
see code below. Any help would be greatly appreciated.
createRequest();
function createRequest() {
var cart = new Cart();
// add in cart
var item = cart.addItem('d81c4666db365b00d901dd0b5e961925');
// set requested for
cart.setVariable(item, 'vs_from', email.origemail);
cart.setVariable(item, 'vs_short_description', email.subject.toString());
cart.setVariable(item, 'vs_description', email.body_text);
var cartmsg = "received from: " + email.origemail + "\n\n" + email.body_text;
cart.setVariable(item,'comments',cartmsg);
var ritmRec = cart.placeOrder();
}
var ritmSysID = "";
var ritmRec = new GlideRecord("sc_req_item");
ritmRec.addQuery("request", rc.sys_id);
ritmRec.query();
if(ritmRec.next()){
ritmSysID = ritmRec.sys_id;
}
var emailRec = new GlideRecord("sys_email");
emailRec.addQuery("uid", email.uid);
emailRec.orderByDesc("sys_created_on");
emailRec.query();
if(emailRec.next()){
GlideSysAttachment.copy("sys_email", emailRec.sys_id, "sc_req_item", ritmRec.sys_id);
}
Solved! Go to Solution.
- Labels:
-
Best Practices
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2018 06:53 AM
This same I did and it worked, I made few changes lets see the output:
createRequest();
function createRequest() {
var cart = new Cart();
// add in cart
var item = cart.addItem('d81c4666db365b00d901dd0b5e961925');
// set requested for
cart.setVariable(item, 'vs_from', email.origemail);
cart.setVariable(item, 'vs_short_description', email.subject.toString());
cart.setVariable(item, 'vs_description', email.body_text);
var cartmsg = "received from: " + email.origemail + "\n\n" + email.body_text;
cart.setVariable(item,'comments',cartmsg);
var ritmRec = cart.placeOrder();
var ritmSysID = "";
var ritm = new GlideRecord("sc_req_item");
ritm.addQuery("request",ritmRec.sys_id); //Changed
ritm.query();
if(ritm.next()){
ritmSysID = ritmRec.sys_id; //Changed
}//Changed
var email_log = new GlideRecord('sys_email');
email_log.addQuery('uid', email.uid);
email_log.orderByDesc('sys_created_on');
email_log.query();
if (email_log.next()) {
var email_sys = email_log.sys_id;
GlideSysAttachment.copy('sys_email', email_sys, 'sc_req_item', ritmSysID);
} else {
var email_sys = 0;
GlideSysAttachment.copy('sys_email', email_sys, 'sc_req_item', ritmSysID);
}
}
Thanks
Shashikant
Hit Helpful or Correct on the impact of response.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2019 10:11 PM
Hi Shashikant,
I am using this exactly (except with my own sys id) and yet the email does come into the sys_email table but then it won't copy to my ritm that has been created?? Is there anything else I should be checking if this doesn't work?