Server JavaScript error Cannot call property size in object com.glide.script.fencing.ScopedChoiceList. It is not a function, it is "number".

Community Alums
Not applicable

I am using the OOB widget SC Catalog Item and cloned to different scoped application. I am getting an error when I am using that widget.

Did anyone faced the same issue? Could you please provide your inputs?

When I check the logs on choiceListQuantity and got an error as mentioned below.

com.glide.script.fencing.ScopedChoiceList

Part of Script from widget:

var clGenerator = new GlideChoiceList();
var choiceListQuantity = clGenerator.getChoiceList("sc_cart_item", "quantity");
var choicelistQuantityData = [];
for (var i = 0; i < choiceListQuantity.size(); i++) {
var choice = choiceListQuantity.get(i);
if (!isNaN(choice.getValue()))
choicelistQuantityData.push({value : parseInt(choice.getValue()), label : choice.getLabel()});
}

1 ACCEPTED SOLUTION

CA4
Kilo Expert

I am dealing with the same issues...

You need to remove the () from after the size (so choiceListQuantity.size not choiceListQuantity.size()).

You are also going to have an issue with choiceListQuantity.get(i), it should be choiceListQuantity.getChoice(i). 

I am now running into another issue with this widget where the selected item is not showing in the form.  When I figure out the issue I'll let you know.

View solution in original post

5 REPLIES 5

CA4
Kilo Expert

I am dealing with the same issues...

You need to remove the () from after the size (so choiceListQuantity.size not choiceListQuantity.size()).

You are also going to have an issue with choiceListQuantity.get(i), it should be choiceListQuantity.getChoice(i). 

I am now running into another issue with this widget where the selected item is not showing in the form.  When I figure out the issue I'll let you know.

CA4
Kilo Expert

Sorry, forgot to mention that isNAN will not work either, so I changed if (!isNaN(choice.getValue())) to if (isFinite(choice.getValue()))

Rakhi Seth
Kilo Contributor

Thanks it was helpful

CA4
Kilo Expert

Ok, so that last thing I had to do was lines 195 to 198: 

data.sc_cat_item = $sp.getCatalogItem({
sys_id: data.sys_id + '',
is_ordering: true
});

I replaced with data.sc_cat_item = $sp.getCatalogItem(data.sys_id);

and now it is functioning enough that I can start my changes to it.

I hope this helps.