How to fill out a catalog variable (Fixed list) from a script

Joshua Comeau
Kilo Sage

Noticed with the following script it is filling out the variable but creating its own choice on the sctask level instead of using the existing variable choice:

 

EX:

JoshuaComeau_0-1720448069190.png

 

Script:

try{ //DO NOT TOUCH

var cartId = GlideGuid.generate(null); //CartID Generates //DO NOT TOUCH
var cart = new Cart(cartId); //Creates New Cart //DO NOT TOUCH
//add your requested item to the cart by sys_id of the catalog item //DO NOT TOUCH
var item = cart.addItem('7893bd301b90f110e010dd3bdc4bcbca', 1); //Adds Facility Request Catalog //DO NOT TOUCH

//populates variable on catalog to submit

var category = gs.info(current.u_category);
cart.setVariable(item, 'category', current.u_category);

var rc = cart.placeOrder(); //Places Order //DO NOT TOUCH
gs.info(rc.number); //DO NOT TOUCH
}//DO NOT TOUCH
catch(ex){//DO NOT TOUCH
gs.info(ex);//DO NOT TOUCH
}//DO NOT TOUCH
//end

1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

Have you made sure the actual value (not label, Name,...) stored in u_category (looks like it's 'home office') exactly matches (space and case-sensitive) the select box variable Value (not the Text label)?

View solution in original post

2 REPLIES 2

Brad Bowman
Kilo Patron
Kilo Patron

Have you made sure the actual value (not label, Name,...) stored in u_category (looks like it's 'home office') exactly matches (space and case-sensitive) the select box variable Value (not the Text label)?

This was exactly what it was the field value were missing _'s