Getting sysid or RITM of just placed catalog item

xiaix
Tera Guru

I am using a custom UI Macro cart for a certain catalog item.

So instead of using the oob "catalog_cart_default", I copied it and created "catalog_cart_default_custom".

I'm using basically the same orderNow() function, but I need to capture the RITM (Requested Item) record that this produces.

How can I do this?

Here's the orderNow() function:

function orderNow()

{

      var m = g_form.catalogOnSubmit();

     

      if (!m)

              return;

      // Disable buttons

      gel("order_now").onclick = "";

      gel("save_this_record_button").onclick = "";

      var item_guid = gel("sysparm_item_guid");

     

      if (item_guid)

              item_guid = item_guid.value

             

      var catalog_guid = gel("sysparm_catalog");

     

      if (catalog_guid)

              catalog_guid = catalog_guid.value

             

      var catalog_view = gel("sysparm_catalog_view");

     

      if (catalog_view)

              catalog_view = catalog_view.value

      g_cart.order(gel("sysparm_id").value, getQuantity(), item_guid, catalog_guid, catalog_view);

      saveThisRecord('submitted');

}

4 REPLIES 4

Brad Tilton
ServiceNow Employee
ServiceNow Employee

Hi David,



I don't know if that's possible from the client side here. Typically in order to get the sys_ids of the ritms ordered, you have to use the request sys_id that you get back from the catalog api and query for its items.


That'd be just fine.   Where is it spitting back the request sys_id ?


Did you find the solution ?
I also need the RITM record


Community Alums
Not applicable

After the cartDetails, you just need to do a GlideRecord to retrieve the RITM.

var cartDetails = cart.orderNow(request);

 

var GlideRecord('sc_req_item);

gr.addQuery('request', cartDetails.request_id);

gr.query();

if (gr.next()){

gr.number

}