RITM is not creating from Catalog item

Neelavathi M
Tera Contributor

Hi All,

 

I have a requirement to Insert a record in RITM table , when user clicks on "Accept as SR" ui action, i am able to see item is added to cart but it is not creating record in RITM table.

 

function createSR() {
    // Create Service Request

    var cartId = GlideGuid.generate(null);
    var cart = new Cart(cartId);
    //add your requested item to the cart by sys_id of the catalog item
    var item = cart.addItem('267f4de4db46f240f063f9c41d9619d7',1);
    gs.log('rcitem+++++++' + item);
    //fill in the variables on the request item form
    cart.setVariable(item, "requested_for", current.u_created_for);
    cart.setVariable(item, "other_short_description", current.short_description);
    cart.setVariable(item, "short_description", ReqNo);
    cart.setVariable(item, "other_description", current.description);
    cart.setVariable(item, "cmdb_ci", '58b77051db59b2004101f3d31d9619c7');
    cart.setVariable(item, "assignment_group", '3d481143dbe18f402149f1c41d9619cc');

    var rc = cart.placeOrder();
  gs.log('rc+++++++' + rc);
}

 

can any one please suggest what changes has to be done in order to insert a record ,

 

Appreciate your quick response.Thanks

 

1 REPLY 1

Peter Bodelier
Giga Sage

Hi @Neelavathi M,

 

You are using the deprecated Cart() function.

Please use CartJS:
CartJS | ServiceNow Developers


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.