Cart API script is not working when it is using as an inbound action

sreejith05
Giga Expert

Hi Team,

I am using the below script to create an RITM using inbound email action, the problem i m facing here is its working perfect when i test it using background scripts, but when i do it as a email inbound action its giving the message "Create RITM using Cart API : did not create or update sc_req_item using current" and the target is showing empty (attached screenshot for reference. Please help me to fix the same.

createRequest();
function createRequest() {
var cart = new Cart();
// add in cart, substitute your cat item sys_id
var item = cart.addItem('3f7e8f5f1b325090b0f210e58d4bcb82');
// set requested for, substitute your requested for
//Set Variables in your Cart Item
cart.setVariable(item,'requested_for','6698154e1b82e850537edc25cc4bcb95');

cart.setVariable(item,'name_of_user','test');
cart.setVariable(item,'purpose','test');
cart.setVariable(item,'ad_account','True');
var cartmsg = "received from: TEST" ;
cart.setVariable(item,'comments',cartmsg);
cart.setVariable(item,'e_mail_address','test@snc.com');

cart.setVariable(item,'job_title','job title');
var rc = cart.placeOrder();
}

1 ACCEPTED SOLUTION

Willem
Giga Sage
Giga Sage

Can you check if the Target table is set on your Inbound Email Action? Judging from the message you get, it looks like it is set to sc_req_item.

If set, the Inbound action will check if a new Record is inserted in that table or updated and will use that as the Target record. Since you do not use any record from a table to insert or update, that message "Create RITM using Cart API : did not create or update sc_req_item using current" will display.

 

Can you check if the order is placed (if you can find it in the request and requested items table)? If so, then you could either set Target table to --None-- or determine what record you want to insert/update after the order and that could be your Target record.

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@sreejith05 

Possibly the user who is sending the email doesn't satisfy the Catalog Item's User Criteria

Refer below link for same issue and the solution

After upgrade from NY to Paris, Using Cart API with Guest User fails if Catalog Item doesn't have Us...

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@sreejith05 

Thank you for marking my response as helpful.

If my response helped you please mark it correct to close the question so that it benefits future readers as well.

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

This really helped!

Willem
Giga Sage
Giga Sage

Can you check if the Target table is set on your Inbound Email Action? Judging from the message you get, it looks like it is set to sc_req_item.

If set, the Inbound action will check if a new Record is inserted in that table or updated and will use that as the Target record. Since you do not use any record from a table to insert or update, that message "Create RITM using Cart API : did not create or update sc_req_item using current" will display.

 

Can you check if the order is placed (if you can find it in the request and requested items table)? If so, then you could either set Target table to --None-- or determine what record you want to insert/update after the order and that could be your Target record.