- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2021 02:32 PM
I would like to understand the Cart API better and I want to know if it is release necessary to execute GlideGuid.generate(null)?
Version #1:
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
Version #2:
var cart = new Cart();
Can I just use version 2 or should I really invoke version #1? What is the difference?
Solved! Go to Solution.
- Labels:
-
Service Portal Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2021 03:38 PM
Hi,
It's to ensure you're using a unique cart. As an example, if you browse the service portal and add an item to your basket, a cart will be presented in the sc_cart table for your user profile with a name of DEFAULT. If you were to then use new Cart().... and not specify a unique name, you would be calling the cart with that default cart and could inadvertently place an order/request with additional RITMs.
As you can see from below, in the portal I've added an item to my basket/cart but haven't checked out.
If I was to then use new Cart() and request say a phone via script, I would submit both the email account and phone under a single REQ.
Calling Version 1 of the script you attached you can see two cart entries, 1 with a completely unique name of a sys_id.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2021 03:38 PM
Hi,
It's to ensure you're using a unique cart. As an example, if you browse the service portal and add an item to your basket, a cart will be presented in the sc_cart table for your user profile with a name of DEFAULT. If you were to then use new Cart().... and not specify a unique name, you would be calling the cart with that default cart and could inadvertently place an order/request with additional RITMs.
As you can see from below, in the portal I've added an item to my basket/cart but haven't checked out.
If I was to then use new Cart() and request say a phone via script, I would submit both the email account and phone under a single REQ.
Calling Version 1 of the script you attached you can see two cart entries, 1 with a completely unique name of a sys_id.