onSubmit Client Script: How to override the dirty form alert box ( "Leave Site? Changes you made may not be saved.") on a onSubmit client script?

Community Alums
Not applicable

Hi,

 

I have a onSubmit client script on a record producer where I throw an alert box. When the user clicks on "Ok" on the alert box- a dirty form error alert box pops up with the text "Leave Site? Changes you made may not be saved." How to override this 2nd alert pop up?

I tried using g_form.modified = false as I saw in few other threads. But that did not work. Any solution to this?

 

Thank you,

Shruthi

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hi Ankur,

 

Thank you for your reply. But a property change would be a global change right? 

We were able to achieve override it with a combination of onSubmit client script and portal_redirect on RP form.

 

Thank you!

View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Shruthi,

that message is out of the box coming from browser and I think it cannot be changed

try this property

glide.ui.dirty_form_supportEnables (true) or disables (false) display of a confirmation message when a form has unsaved changes and the user leaves the form through any means except a submit (such as using the green back arrow, any form button, or other). This property is not supported in Safari.

  • Type: true | false
  • Default value: true
  • Location: System Property [sys_properties] table

https://community.servicenow.com/community?id=community_question&sys_id=c2123081db986740200f0b55ca96...

https://www.servicenowguru.com/scripting/client-scripts-scripting/custom-dirty-form-message/ 

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Community Alums
Not applicable

Hi Ankur,

 

Thank you for your reply. But a property change would be a global change right? 

We were able to achieve override it with a combination of onSubmit client script and portal_redirect on RP form.

 

Thank you!

Hi Shruthi,

Just for ref sharing link

https://community.servicenow.com/community?id=community_question&sys_id=2abd56f6db07f300d82ffb243996...

please share your solution as well.

Regards
Ankur

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader