Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

creating RITM using inbound action and cart api

Rahul Raja Sami
Tera Guru

 

Hi 

 

Trying to create RITM using inbound action and below cart API

target table: sc_req_item


createRequest();
function createRequest() {
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
//give sys_id of catalog item
var item = cart.addItem('0498ad2987472450d0d4ca27cebb35cc', 1);
cart.setVariable(item,"requested_for", gs.getUserID());
cart.setVariable(item,'short_description',email.subject);
cart.setVariable(item,'please_select_the_request','Active Directory');
var rc = cart.placeOrder();
var tsk = new GlideRecord('sc_task');
tsk.addQuery('request', rc.sys_id);
tsk.query();
while (tsk.next()) {

tsk.assignment_group = 'd625dccec0a8016700a222a0f7900d06' ;// add your value
tsk.short_description = email.subject;
tsk.description = email.body_text;

tsk.u_sub_category = 'Active Directory'; //add your value

}
}

 

but after using this the sys email table target record is getting updated and this error showing on the log

 

RahulRajaSami_3-1669135032798.png

 

error

RahulRajaSami_2-1669134901383.png

 

and 2 RITM's are getting created

RahulRajaSami_1-1669134874407.png

 

why this is happening?

 

1 ACCEPTED SOLUTION

I have configured Inbound action for Task table and everything works fine.

View solution in original post

19 REPLIES 19

what I observed is 

when I use current.insert() in my code, the result is

RahulRajaSami_0-1669147923710.png

 

when I don't use current.insert();

RahulRajaSami_1-1669147967720.png

 

 

Mike_R
Kilo Patron
Kilo Patron

If you are open to using flow designer, this can be very easily achieved with no scripting

 

Mike_R_0-1669148720865.png

 

ya mike, we can do that.

but I want to know why this is not working fine?

 

It’s because inherently an inbound action creates a new record on the target table. 
and then your are also creating a new record using script. Therefore that’s why there are two ritms created

then what is the solution ?