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

Custom View Button to dynamically display visualforce pages



I am trying to override the view button in custom object with a custom view button. My custom button should dynamically display visualforce pages based on  a field value.


For eg: I have two Visualforce Pages: VF1 and VF2 and a picklist - testpick__c = 1;2


If the record has testpick__c = 1 --> Display VF1 when custom view button is clicked

If the record has testpick__c = 2 --> Display VF2 when custom view button is clicked


It would greatly help me out if someone could share some code or suggest an approach that I could use to implement this functionality.



Dave Miller.ax1920Dave Miller.ax1920
Go to VF1. use the action= in the apex:page to do the test in the controller and redirect to VF2 if needed

Hi Victor, 


I think you should look at using a single controller and by setting setRedirect(false), so that the data persists between the calls and using the updated data the 2nd page can be shown or redirected to. You may want to refer to the following URL for more details :