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

Can 1 custom button lead to 1 of 2 Visualforce pages



I currently have a custom detail page button on a custom object that simply sends the person clicking the button to a PDF Visualforcef page.  I just had to create a second Visualforce page that is similar but slightly different than the first one.


My question is, can I manipulate the custom button URL so that, if someone selects a value in a picklist field on  the object, then 1 of the Visualforce pages is rendered.  If a person selects a different picklist option in that picklist field, the other VF page is rendered.


Basically I need to use 1 custom button to send the user to 1 of 2 different VF pages, and the page they go to needs to depend on the picklist option chosen in a picklist field on the object.




on the custom button, u can use "execute javascript " behaviour and content source "on click  javascript" , where u can write if / else logic by using merge field to open a required page in modal dialog





You can use the below sample code in the custom button url - /apex/{!IF( Account.Type== 'Customer' , 'VFPage1', 'VFPage2')}


where VFPage1 and VFPage2 are the two VF pages which are re-directed based on the Account Type picklist feild.


Hope this helps.