Catalog Client script not working in portal

ServicenowDev19
Tera Contributor

I have written catalog client script on variable set.Whenever i add record in multirow variable set i need to get record count in alert.This script is working when i exceute in TRY IT Scetion. But this script is not working in sp portal when i add row in multi row variable set.

I am geeting the error--Error There is a JavaScript error in your browser console 

 

Script:

function onSubmit() {


var mrvsStr = parent.g_form.getValue("additional_users");
var mrvsData = JSON.parse(mrvsStr).length + 1;
//var obj = JSON.parse(mrvsStr);
//var length1 = obj.length;
alert('Number of rows in MRV is - ' + mrvsData);
//parent.g_cart.setQuantity(mrvsData);
parent.g_form.setValue('price',mrvsData);

return true;

 

Please help me why this script is not working in portal.

 

 


}

1 ACCEPTED SOLUTION

Hi,

You have to put below line in separate onLoad client script created on catalog Item (Not in variable set client script)

this.my_g_form=g_form;

AnilLande_1-1680615270829.png

 

and use the script provided by me in onSubmit client script for portal:

AnilLande_0-1680615237375.png

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

View solution in original post

21 REPLIES 21

Ashir Waheed
Kilo Sage
Kilo Sage

Hi @ServicenowDev19 

 

If the Catalog Client Script in not working in the portal. Please check the following steps.

 

1. Open the Catalog Client Script, and select UI action as Both or ALL so it will run on portal too.

AshirWaheed_0-1680603507314.png

2. Verify that script runs when click on the "TRY IT" on the catalog item in the instance.

 

Regards

Ashir Waheed

Yes i have selected the UI type as both but not working.

 

Teja11
Giga Guru

HI @ServicenowDev19 ,

 

Teja11_1-1680603521381.png

 

select the UI Type as All as in the above image

 

Regards,

Teja

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

Yes i have selected that UI type but it is not working in portal,Why