Email attachments aren't getting passed on to Request, RITM, or Task tickets
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2023 12:15 PM
Hello all,
I'm trying to figure out why I can't get email attachments to be added to my Request tickets generated from inbound email actions. Whenever I look up the email that came in (System Mailboxes - Received), the attachment is there, but drilling down a little shows that the Action was --None--. I've looked up some other community questions and it seems like I might need to use GlideSysAttachments.copy(), but I don't know where to put it in my script. I'm assuming for the arguments of that function I need the sys_email_attachments table, the ability to call the sys_id of that attachment, the sc_request table (since I want to have the attachment on this generated request) and then call the sys_id of the request I generated. I'm not certain what those would be though:
GlideSysAttachment.copy('sys_email_attachment', <no idea this variable>, 'sc_request', <no idea this variable>)
What are those variables I need to place there?
Below is my code I've used in my inbound email action to generate the Request, RITM, and Task tickets:
(function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier)
{
/*********** Update RITM *************/
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem('6585a9c31be0e1107d0354e0604bcb2b'); //Catalog Request Item
cart.setVariable(item, 'requested_for', gs.getUserID());
cart.setVariable(item, 'is_operations', email.body_text);
cart.setVariable(item, 'short_description', email.subject);
cart.setVariable(item, 'email', email.origemail);
var rc = cart.placeOrder();
gs.addInfoMessage(rc.number); // this is the request number not the RITM #
var grRITM = new GlideRecord('sc_req_item');
grRITM.addQuery('request',rc.getValue('sys_id'));
grRITM.query();
if(grRITM.next()) {
grRITM.setDisplayValue('assignment_group', '');
grRITM.update();
/*********** Update Request *************/
current.setDisplayValue(short_description, "Test text 1");
current.setDisplayValue(description, "Test text 2");
current.update();
}
})(current, event, email, logger, classifier);
Where would I place this function to get my emails to attach correctly? Would the placement be different if I want attachments to also go to the RITM and Task tickets?
Thank you for any help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2023 04:55 AM
@Lee Kraus2 after request is created write this line
// Copy attachments to the target record GlideSysAttachment.copy("sys_email", sys_email.getUniqueValue(), target.getTableName(), target.getUniqueValue());
Bharath Chintala
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2023 11:06 AM
So here's where I put the code, but it didn't work. Where should I place this line?
(function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier)
{
/*********** Update RITM *************/
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem('6585a9c31be0e1107d0354e0604bcb2b'); //IS Ops ticket Catalog Request Item
cart.setVariable(item, 'requested_for', gs.getUserID());
cart.setVariable(item, 'is_operations', email.body_text);
cart.setVariable(item, 'short_description', email.subject);
cart.setVariable(item, 'email', email.origemail);
//cart.setVariable(item, 'business_service', '');
//cart.setVariable(item, 'requester_priority', '2');
//cart.setVariable(item, 'requester_priority', '1');
var rc = cart.placeOrder();
gs.addInfoMessage(rc.number); // this is the request number not the RITM #
var grRITM = new GlideRecord('sc_req_item');
grRITM.addQuery('request',rc.getValue('sys_id'));
grRITM.query();
if(grRITM.next()) {
grRITM.setDisplayValue('assignment_group', '');
grRITM.update();
// Copy attachments to the target record
GlideSysAttachment.copy("sys_email", sys_email.getUniqueValue(), target.getTableName(), target.getUniqueValue());
/*********** Update Request *************/
current.setDisplayValue(short_description, "Test text 1");
current.setDisplayValue(description, "Test text 2");
current.update();
}
})(current, event, email, logger, classifier);