Catalog item not working in portal

Tim Saunders
Tera Guru

I created a catalog item that works fine in the standard GUI but fails in the portal. The fields, UI actions, and clients scripts all behave as expected but the screen freezes when I select Order Now or Add to Cart. I did manage to find an error: "could not find script to run for this action" but I don't know what specific script/action it's referring to. I haven't made any changes to any core items (scripts, forms, etc.) so I'm not sure what the problem is. Any advice/direction would be appreciated.

1 ACCEPTED SOLUTION

Tim Saunders
Tera Guru

Rookie javascript mistake. Although I use getIntValue for each box and then add the numbers I was writing a number into the 'total' field when setValue clearly calls for a String... Once I added a step to convert the value into a string the item works properly.

View solution in original post

11 REPLIES 11

I didn't mean adding anything to the cart, I just meant if you click on the cart to go to it without trying to submit anything.  Just view the cart without adding any items to it. Basically go to the portal and click Cart and see if it hangs up or if it loads the empty cart.

 

Also, I'm curious if you take off the cart layout for submitting and test an item without the cart layout if you still get the error message.

Tim Saunders
Tera Guru

Incidentally, when I click the link to the URL https://devxxxxx.service-now.com/api/sn_sc/v1/servicecatalog/items/2cf38019dbf92300a3d97fcfbf9619ee/order_now, I'm taken to a page that states "GET method not supported for API". Keep in mind I have not written any code for this, just used existing OOB functionality

Hi Tim ,

 

Is this issue you are talking about?

 

https://hi.service-now.com/kb_view.do?sysparm_article=KB0656139

 

Thanks,

Sumanth

Tim Saunders
Tera Guru

OK, so apparently I was wrong. I DID write a client script that is causing the problem. The purpose of the script is to update a value (total) based on the values of 4 other fields (disk1, disk2, disk3, disk4). There are 4 identical copies of the script, one for each field being monitored for change. When active, the script does what I want (update the 'total' field with the added value of the 4 fields) but causes a problem when ordering or adding the item to cart. When inactive, the numbers are obviously not added but the item can be ordered/added to a cart. disk1 and disk2 are required but disk3 and disk4 are optional and may not contain data.

 

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}

var v1 = g_form.getIntValue('disk1');
var v2 = g_form.getIntValue('disk2');
var v3 = g_form.getIntValue('disk3');
var v4 = g_form.getIntValue('disk4');

var vtotal= v1 + v2 + v3 + v4;

g_form.setValue('total',vtotal);

Prins Kumar Gup
Giga Guru

Hi tim.saunders@guggenheimpartners.com,

Can you share the error screenshot?

 

TIA

Prins