The g_form.submit function has no meaning on a catlog item.

Vengeful
Mega Sage

I have a catalog item then created a catalog client script and Script Include. I used onSubmit since I am not using Service Portal.

This is to check if the new hardware has existing record. If existing, it will not proceed with the request.

If not, it will proceed.

The SI and Catalog client script is working as expected for an existing record.

Vengeful_0-1729476349535.png

 

But for new record, there is an error "The g_form.submit function has no meaning on a catlog item. Perhaps you mean g_form.addToCart() or g_form.orderNow() instead".

Vengeful_1-1729476402380.png

 

Catalog client script

Vengeful_2-1729476646122.png

Script include

Vengeful_3-1729476660681.png

 

I change the g_form.submit(); to g_form.orderNow(); but nothing happens when I click Order Now button.

 

 

1 ACCEPTED SOLUTION

Hitoshi Ozawa
Giga Sage
Giga Sage

It's because you're making an asynchronous call from Client Script. Asynchronous mean in the background, so your form is being submitted before the reply from Script Included.

You'll need to check the value onChange before it's submitted. Create a onChange Client Script on field "shortDescription" and call your Script Include from there instead of onSubmit.

View solution in original post

3 REPLIES 3

Hitoshi Ozawa
Giga Sage
Giga Sage

It's because you're making an asynchronous call from Client Script. Asynchronous mean in the background, so your form is being submitted before the reply from Script Included.

You'll need to check the value onChange before it's submitted. Create a onChange Client Script on field "shortDescription" and call your Script Include from there instead of onSubmit.

Thanks @Hitoshi Ozawa - san.

I created onChange for short_description field and call the SI.

Then created onSubmit to prevent the form from being submitted when existing record is found.

There's 2 ways to do this.

1. Make short_description field mandatory . When there is an error onChange, initialize the short_descripton field. This will cause the form to error when it is submitted because the short_description is empty.

2. Create a hidden true/false field on the form with a default value of true. When there is an error onChange, set this field to false and to revert it back to true when there is no error. Have onSubmit to check that this hidden field is true. Caution: Don't use global variable to hold value instead of hidden field because a user can open 2 forms and the global variable will be shared by these 2 forms.

 

Method 1 is preferred but it erases what's been entered so user may complain.