Disable alert "Changes you made may not be saved." for particular catalog form on Service Portal

Community Alums
Not applicable

Hello Developers,

We have requirement for Service Portal catalog form. We need to redirect from one form to another form without knowing the end user. If end user selects any particular value then form will redirect to another form but we are getting alert box -
"Changes you made may not be saved".  Thing is if they click on cancel, they will not redirect to another form and we want to prevent this case.                                                                                                                           

Is there anyway to disable this alert for particluar catalog form only.

find_real_file.png

 

Thanking you.

Regards,

Akshay

1 ACCEPTED SOLUTION

correct! so we cant say that it comes from browser level. 

although before redirecting we can use this code to avoid that popup.

top.window.onbeforeunload = null;

View solution in original post

25 REPLIES 25

correct! so we cant say that it comes from browser level. 

although before redirecting we can use this code to avoid that popup.

top.window.onbeforeunload = null;

I had this similar question in past to change that message.

Also I could find that such type of message do come using chrome. I haven't tried with other browser

for reference:

https://www.reddit.com/r/vivaldibrowser/comments/f3hvpv/leave_site_changes_you_made_may_not_be_saved...

https://support.google.com/chrome/thread/8565697?hl=en

Regards
Ankur

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

Community Alums
Not applicable

Hello Hammad,

 

Thank you so much. It's working. 

 

Regards,

Akshay

I am gald its working. Happy coding

 

thanks 

hammad

Hello @hammad@hammad ul aziz 

Can you help this as I have the same problem of an alert appearing on my onSubmit client script.

I tried your code but it didn't work, can you help please?

function onSubmit() {
	//Type appropriate comment here, and begin script below
	var num = g_form.getValue("number");
	if(num) {
		//g_form.submit();
		top.window.onbeforeunload = null;
		top.window.setTimeout(redirectUrl,1000);
	}
	function redirectUrl() {
		top.window.location = "https://digitalenergydev.service-now.com/sn_customerservice_l3_case_type.do?sysparm_query=number=" + num;
	}
}