How to get the current cart in service catalog?

Tom Sienkiewicz
Mega Sage

Hi, I have been trying to implement a "save catalog offer" functionality and am currently thinking about one of key points:

THe current cart with all contents should be saved for later checkout. This is not a problem generally, but I have one question - what would be the best way to get the record of the current cart open in the service catalog? I have checked the API and there is a getCart() function, which is very nice but has one nasty habit of emptying all contents of the current cart.

I suppose I could write another function that will override the constructor but am a bit stuck how to do it - if anyone has done anything similar, please help

Other way I can think of is to use glide record, but this may not always work. Do you guys know of any other ways to get the current sc_cart record / sys_id from inside a UI Macro? Many thanks!

2 REPLIES 2

jake_mckenna
ServiceNow Employee
ServiceNow Employee

I would say check out this post on some possible solutions. The one this directly links to is what i have done in the past to extend cart() and allow me to continue to add to the cart and work around that issue.



Re: How to add to a current cart instead of new cart()


Thanks a lot, I will try to extend the base class like in your example.