- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2020 11:32 AM
Hi all,
I've got a catalog item with an onSubmit catalog client script that builds a URL, and then when the user submits the form they need to be redirected to that URL. Did something with "top.window.location" break in New York? The script is working about half the time, sometimes it correctly directs the user to the URL in the script, and sometimes it ignores that script. Anyone else seeing this behavior or see an issue with my script? Thanks!
Here's the script:
function onSubmit() {
var req = g_form.getValue('enter_your_vsa_request_number_to_get_started');//this is a reference field to the [sc_request] table
var URL = "itc?id=sc_request&table=sc_request&sys_id="+req;
alert('You will be directed to the Selected Vendor Assessment Request. Please click OK.');
top.window.onbeforeunload = null;//this removes the popup that asks if you want to leave
top.window.location = URL;
}
Solved! Go to Solution.
- Labels:
-
Service Portal Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2020 01:06 PM
You could try a good, old-fashioned setTimeOut. Move the last part of your code into a separate function and have it call-back after a second or so.
function onSubmit() {
var req = g_form.getValue('enter_your_vsa_request_number_to_get_started');//this is a reference field to the [sc_request] table
var URL = "itc?id=sc_request&table=sc_request&sys_id="+req;
alert('You will be directed to the Selected Vendor Assessment Request. Please click OK.');
top.window.onbeforeunload = null;//this removes the popup that asks if you want to leave
setTimeout(sendOff(URL), 1000);
}
function sendOff(URL) {
top.window.location = URL;
}
That seems to be working every time for me...
If this was helpful or correct, please be kind and remember to click appropriately!
Michael Jones - Proud member of the CloudPires team!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2020 01:06 PM
You could try a good, old-fashioned setTimeOut. Move the last part of your code into a separate function and have it call-back after a second or so.
function onSubmit() {
var req = g_form.getValue('enter_your_vsa_request_number_to_get_started');//this is a reference field to the [sc_request] table
var URL = "itc?id=sc_request&table=sc_request&sys_id="+req;
alert('You will be directed to the Selected Vendor Assessment Request. Please click OK.');
top.window.onbeforeunload = null;//this removes the popup that asks if you want to leave
setTimeout(sendOff(URL), 1000);
}
function sendOff(URL) {
top.window.location = URL;
}
That seems to be working every time for me...
If this was helpful or correct, please be kind and remember to click appropriately!
Michael Jones - Proud member of the CloudPires team!
Michael D. Jones
Proud member of the GlideFast Consulting Team!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2020 01:52 PM
Hi Michael...well oddly that worked the first couple tests...but now 3 times in a row it ignores the redirect. I put in a 2nd alert just to be sure the function is running and it is. Any thoughts?
function onSubmit() {
//Redirect the user to the Vendor / Solutions Assessment request
var req = g_form.getValue('enter_your_vsa_request_number_to_get_started');
var URL = "itc?id=sc_request&table=sc_request&sys_id="+req;
alert('You will be directed to the Selected Vendor Assessment Request. Please click OK.');
top.window.onbeforeunload = null;//this removes the popup that asks if you want to leave
setTimeout(sendOff(URL), 1000);
}
function sendOff(URL) {
alert('function is running');
top.window.location = URL;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2020 02:03 PM
so strange...did it twice in a row, worked first, didn't work 2nd time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2020 02:19 PM
Did you check the value of URL in second run? Try initializing it to null.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2020 03:46 PM
Hi Yogi,
I did add the URL to the alert in the funtion and it is building correctly there...what do you mean my initializing it to null?