function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Erik Swiderski 8Erik Swiderski 8 

Prevent navigating away from page

I have a visualforce page on the record detail page layout of an object.

If certain criteria is met, I need the user to interact with the page and enter some information. How can I prevent navigating away from the record detail page if this information has not been entered? This is currently in classic, and ideal solution would also be compatible in lightning.
Narender Singh(Nads)Narender Singh(Nads)
Hi Erik,
Refer to this post: https://developer.salesforce.com/forums/?id=906F0000000ApecIAC

Let me know if it helps
Thanks!
Erik Swiderski 8Erik Swiderski 8
Hi Narender,

Thanks for the reply- I did check out that link but unfortunately that wasn't working for me. I think the problem is that the code mentioned in the link has to be in the record detail page. The vf page I created is added to the layout of the record detail, and the standard record detail page is used- not overriden with vf.

If certain criteria is met the user should enter data in it before closing the tab or navigating away from the record.