sn_sc.CartJS() error "can not find default value"

Eckhard
Tera Contributor

Dear Community,

I am trying to create shopping cart items within a script with sn_sc.CartJS() on my Tokyo PDI.

I tried this in the script editor (Background scripts) - see code below.

I always receive the error message: "

com.glide.script.RhinoEcmaError: Cannot find default value for object

and it points to the line: 

cart.addToCart(request);

Here my small code:

 

var quantity = 1;
var	myID = '6816f79cc0a8016401c5a33be04be441'; //sysid of user admin
var cat_item = ('21874084472311104306bce5536d43a6');//sysid of catalog item
var cart = sn_sc.CartJS();
var variables  = {};
var request = {
                    'sysparm_id': cat_item,
                    'sysparm_quantity': quantity,
                    'sysparm_requested_for': myID,
                    'variables': variables
                };
cart.addToCart(request);

 

I also tried to handover a string to the CartJS-function but I always get the same error.
Many thanks for your ideas.

Best regards

Eckhard

1 ACCEPTED SOLUTION

Saurav11
Kilo Patron
Kilo Patron

Hello,

 

Please use the below line:-

 

 

var cart = new sn_sc.CartJS();

 

 

Saurav11_0-1669657185940.png

 

 

Please mark my answer as correct based on Impact. 

View solution in original post

1 REPLY 1

Saurav11
Kilo Patron
Kilo Patron

Hello,

 

Please use the below line:-

 

 

var cart = new sn_sc.CartJS();

 

 

Saurav11_0-1669657185940.png

 

 

Please mark my answer as correct based on Impact.