Alternative for the Global script include "Cart" function
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-19-2023 06:51 AM - edited ā12-19-2023 06:51 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-19-2023 06:53 AM
Hi @Community Alums
There is new CartJS API that you can use.
CartJS | ServiceNow Developers
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-19-2023 07:43 AM
Hi @Saurabh Gupta ,
Thanks for the response. Using this CartJS API, I can submit a request. But I found a issue with this.
First I need to use ->cart.orderNow(request); and later I need to change to-> cart.checkoutCart(request);. So, then I can submit a request. If I only use "orderNow" I can just add the item into cart but again if I remove everything from cart and change to "checkoutCart" then the order is submitted.
Apart from the above issue, there is a " Script Affected Record Summary" where the data shows list of records getting updating, inserting and deleting. Is this any issue or the expected behavior?
var cart = new sn_sc.CartJS();
var newItem = cart.addToCart({
"sysparm_id": "854df61fdbdsds0529cfba66896194b",
"sysparm_quantity": "1",
"sysparm_requested_for": "00aad324fs2c151076fb628f7b4bcb3d",
"variables":{
'request_for_access' : '100'
}
});
var checkoutInfo = cart.orderNow(request);//for the first trigger
var checkoutInfo =cart.checkoutCart(request);//later I need to comment the above code and need to update to this code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-20-2023 05:26 AM
No Issues.
Thanks and Regards,
Saurabh Gupta