Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

On Submit client script runs multiple times on Service Portal for request item when used on a OOB form widget.

Shane38
Tera Expert

 

Hi All

I am having issues with implementing a solution that allows a user to update a request item from the Service Portal using a page with a copy of the form widget.

I first thought it was my environment or changes to the form widget that I made, but my developer instance behaves the same. To replicate is very simple. I created an on submit client script of a catalog item and checked the box so it applies on requested items . (I also tried one on the sc_req_item table. Both caused the same issue.)

To replicate,

1) The client script is something simple like:

function onSubmit() {
//Type appropriate comment here, and begin script below
var value = g_form.getValue('fieldname');
alert(value );
}

2) Then create a blank new Service Portal page with an id and add the OOB form widget. 

3) Launch the Service Portal page with a open request item id (note if using catalog item client script then item must be of same type)

e.g.

https://instancename.service-now.com/sp/?id=test_page&table=sc_req_item&sys_id=417c256bdba94010d7ad9...

4) Make a change and save the form.

The alert pop-up appears more than once. (in fact sometimes multiple times)

Would this be a bug or do onSubmit client scripts not allow this?

Thanks for whomever takes the time. BTW I running on Madrid.

Regards

Shane

1 REPLY 1

Harshad Wagh
Tera Guru

can you modify it something like this?

 

function onSubmit() {
//Type appropriate comment here, and begin script below
var value = g_form.getValue('fieldname');
alert(value );

return true;
}

 

Thanks

Harshad