Service Request - Cart API / generate request programmatically

 see the docs

 

var cart = new sn_sc.CartJS();
var item =
{
'sysparm_id': '0d08837237153000158bbfc8bcbe5d02',
'sysparm_quantity': '1',
'variables':{
'carrier': 'at_and_t_mobility',
'data_plan': '500MB',
'duration': 'eighteen_months',
'color': 'slate',
'storage': 'sixtyfour' 
}};
//var cartDetails = cart.addToCart(item); 
var
cartDetails = cart.orderNow(request);
gs
.info(JSON.stringify(cartDetails));
//-- in case of errors, this will throw the error:
gs.print(JSON.stringify(cartDetails)); 
 
try also the submitOrder() and orderNow() functions 
or this format:

gs.include('Cart'); var cart = new Cart(); var item = cart.addItem('d95447ce1b973010987d1fc3b24bcba0'); cart.setVariable(item, 'short_description', 'test'); cart.setVariable(item,'description','test test'); var rc = cart.placeOrder(); gs.print(rc.number);
 

 

Comments

Popular posts from this blog

GlideRecord setValue

URL link in addInfoMessage

variable advanced reference qualifier example