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
AmitSahuAmitSahu 

Prevent user from going away from a page..

Hi All,

 

Can any one point me to a direction where I can prevent user from moving away from a record/pagelayout without filling a description field ?

 

Thanks in advance for your valueable input...

 

Regards

venkat-Dvenkat-D

If its a standard page layout just use validation rule ISBLANK(field name). If it is in a visualforce page, you can use either javascript or validation in controller and if value is null then display error message with alert() in javascript and <apex:pagemessage> in vf page.

AmitSahuAmitSahu

Thanks for your idea. It will work for a normal scenario.But let me be more descriptive.....

 

The Object 1 is the record where I am working (a VF page ). On this page I have a button  which indicates that I am working on the record. The click of this button creates one new record in the Object 2 (in the background). There is another button (b2 ) without clicking on that I should not be allowed to move away from that page ...... 

 

Any thoughs now... and the requirement is for an alert and not the inline error ....  :(

 

venkat-Dvenkat-D

Here is my thought..

Have two two variables which holds whether each button is clicked or not. If the user clicks on any other buttons before clicking second button..you can use java script validation to check whether both boolean values are true or not.

 

If the user closed the window directly without navigation..i am also doomed :)

AmitSahuAmitSahu

Hummm ....

 

There is no need of the variable if I want to check if one button is clicked or not. We can directly check that by other means. But the issue is let's say I am on a X Case record and I clicked on Leads tab ... I want the user to be prevented to do this untill he clicks second button.

 

May be I am not clear enough about explaining the requirement ... :)