Record Producer - Redirect to External URL Without "Leave Site Without Saving" Browser Prompt

manishkrpal
Tera Contributor

I'm facing an issue with a Record Producer in HRSD and would appreciate any suggestions.

Requirement

I have a Record Producer with two variables:

  • q1_help_area
  • q2_details

One of the choices in q1_help_area is Workday.

When a user selects Workday:

  1. The q2_details variable is hidden.
  2. A message/alert should inform the user that this request must be submitted through Workday.
  3. The user should then be redirected automatically to the Workday URL without clicking the Submit button or any other button.

Current Implementation

I'm using an onChange Client Script on q1_help_area.

The script successfully:

  • Detects the Workday selection.
  • Hides the q2_details variable.
  • Displays the alert/message.
  • Attempts to redirect using window.location.href.

Problem

Because the Record Producer form has been modified, the browser/ServiceNow displays the standard warning:

"Do you want to leave this site? Changes you made may not be saved."

The user must click Leave before the redirect occurs.

This creates a poor user experience because the requirement is for the redirect to happen automatically without any additional confirmation.

What I've Tried

  • window.location.href
  • window.open()
  • top.location.href
  • Delayed redirect using setTimeout()

If I somehow prevent the "Leave site" warning, the redirect itself no longer occurs. The redirect only happens after the user manually clicks Leave.

My Questions

  1. Is there any supported way in ServiceNow to redirect a user from a Record Producer to an external URL without triggering the "Leave site without saving" prompt?
  2. Is this behavior controlled by the browser rather than ServiceNow?
  3. Is there an OOB property, API, or supported approach to achieve this seamless redirect?
  4. Has anyone implemented a similar Workday redirection from a Record Producer?

Any guidance or best practices would be greatly appreciated.

Thank you!

0 REPLIES 0