Cloned SC Catalog Item widget not working.

abhi_29
Giga Expert

Hi there,

I am trying to clone the SC Catalog Item widget and making it work for a record producer in the portal. But the cloned widget is throwing a javascript error in the console and also the record producer is not getting loaded. I have tried to use it for a catalog item but still getting the same error. I am passing the sys_id of the record producer as a url parameter but I am getting the following error: 

 

find_real_file.png

Just to note, the cloning process worked fine when I tried to do it in a licensed instance. Its only in the personal instance I am getting this sort of error. Also the code which is throwing this error works fine in OOB widget. Is it some kind of limitation only applicable to personal instances ? Thanks in advance.

1 ACCEPTED SOLUTION

Oleg
Mega Sage

The problem is: you cloned the code written for Global scope to scoped application. It required frequently to make some small (or not so small) changes in the server code of the widget.

In you case you have to change the lines (74-78 of Madrid code)

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()});
}

to for example the following:

for (var i = 0; i < choiceListQuantity.getSize(); i++) {
	var choice = choiceListQuantity.getChoice(i);
	if (!isNaN(choice.value))
		choicelistQuantityData.push({value : parseInt(choice.value, 10), label : choice.label });
}

and the lines (187-190)

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

to

data.sc_cat_item = $sp.getCatalogItem(String(data.sys_id), true);

After that the widget should work.

View solution in original post

3 REPLIES 3

SatheeshKumar
Kilo Sage

Try cloning your yourr widget in global scope!! May be some functions are restricted for custom apps.

Oleg
Mega Sage

The problem is: you cloned the code written for Global scope to scoped application. It required frequently to make some small (or not so small) changes in the server code of the widget.

In you case you have to change the lines (74-78 of Madrid code)

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()});
}

to for example the following:

for (var i = 0; i < choiceListQuantity.getSize(); i++) {
	var choice = choiceListQuantity.getChoice(i);
	if (!isNaN(choice.value))
		choicelistQuantityData.push({value : parseInt(choice.value, 10), label : choice.label });
}

and the lines (187-190)

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

to

data.sc_cat_item = $sp.getCatalogItem(String(data.sys_id), true);

After that the widget should work.

Thanks a ton ! This worked like a charm !