Attachment on Inbound Actions - CART API

azenith_moreno
Tera Contributor

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.

1 ACCEPTED SOLUTION

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


View solution in original post

12 REPLIES 12

Yep this would be the way to grab the ritm id.


Thank you very much CK/Brad.



Working now as expected


Hi Azenith,



I am working on the same requirement which you had posted here.


But am not able to copy the attachment to RITM.


Could you please explain me hoe to do it.?



Also, what should be placed in <ritem_sys_id> of below code.


  1. Packages.com.glide.ui.SysAttachment("sys_email", emailRec.sys_id, "sc_req_item", <ritm_sys_id>);


Thanks in advance.



Regards,


Sowmiya


the whole code should look like this ...



var cart = new 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();



      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("sys_email", emailRec.sys_id, "sc_req_item", ritmRec.sys_id);  


      }  


Hi Kalai,



It's not working.


I can see some error while processing the email,


Error processing inbound action 'SAP Workflow'


org.mozilla.javascript.EvaluatorException: Java constructor for "com.glide.ui.SysAttachment" with arguments "string,string,string,string" not found. (<refname>; line 49)



Regards,


Sowmiya M