- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-22-2020 12:58 AM
Hi all,
I'm tring to populate variables in cart api,
Below is my coding:
var cartId = GlideGuid.generate(null); var cart = new Cart(cartId); var item = cart.addItem('e46305bdc0a8010a00645e608031eb0f'); cart.setVariable(item,'os','Linux Red Hat'); var rc = cart.placeOrder(); gs.addInfoMessage(rc.number);
My question is how to populate a variable in variable set using cart.setVariable() method, thanks in advance!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-24-2020 10:49 AM
Use the same approach, when a VarSet is added to a Catalog Item its variables are accessible in the same way as its own.
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem('9aa4f8f1db002010189f2706ca9619ce');
cart.setVariable(item,'process','Process 123');
cart.setVariable(item,'source','Source 123');
var rc = cart.placeOrder();
gs.addInfoMessage(rc.number);
See the following screenshots
Cheers,
Oscar Lopez
Please mark this as helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-24-2020 10:05 PM
Hi,
it should be in similar way as normal variable
cart.setVariable(item,'my variable','my variable value');
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader