Return the new RITM Number after CartJS.checkoutCart()

subhadeep1618
Tera Guru

Hi All, 

I have been successfully able to create a new service request through scripting by using the CartJS API.

My code is given below - which is perfectly working.

Now what I want is - to return the new RITM Number after the last step in the below code.

Any help would be much appreciated.

var cart = new sn_sc.CartJS();

    var ritm = {
      sysparm_id: "3ecb3552979f3110060cbb5ef053afcf",
      sysparm_quantity: "1",
      sysparm_requested_for: inputValues.requested_for,
      variables: {
        requested_for: inputValues.requested_for,
        requested_by: inputValues.requested_by,
        os_type: inputValues.os_type,
      },
    };

    cart.addToCart(ritm);
    cart.checkoutCart(); //working perfectly fine - how to return this new RITM number?

 


Please mark this post as a solution and also as helpful, if this resolves your issue or query.

Thanks,
Subhadeep Ghosh.
1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hello @subhadeep1618 ,

 

You can use the below script to get the REQ number, for getting RITM number query the table using GlideRecord.

 

var request = cart.checkoutCart();
var request_number = request.request_number;
 
If this solves your issues/query, mark this as correct and helpful.
 
Thanks
Anand

View solution in original post

2 REPLIES 2

Community Alums
Not applicable

Hello @subhadeep1618 ,

 

You can use the below script to get the REQ number, for getting RITM number query the table using GlideRecord.

 

var request = cart.checkoutCart();
var request_number = request.request_number;
 
If this solves your issues/query, mark this as correct and helpful.
 
Thanks
Anand

Hi @Community Alums ,

Thanks a lot for your help.

Yes, this works.

In fact, I returned the entire object and it looks even better.

{
  "result": [
    {
      "number": {
        "request_number": "REQ0010112",
        "request_id": "32390267971bb510060cbb5ef053afc3"
      }
    }
  ]
}

 


Please mark this post as a solution and also as helpful, if this resolves your issue or query.

Thanks,
Subhadeep Ghosh.