+ Start a Discussion
Max_gMax_g 

Creating Custom Button

I have a VF page that uses a custom object that has a master/detail relationship to account. 

 

I want to use this VF page as a button on the account page.  I need to account ID to drive my VF page.  If I convert from a standard controller to a custom controller will I be able to access this VF page from an account?

 

Best Answer chosen by Admin (Salesforce Developers) 
Bhawani SharmaBhawani Sharma
Yes. You can create a custom button of URL type. URL will be
/apex/PageName?id={!Account.Id}

All Answers

Bhawani SharmaBhawani Sharma
Yes. You can create a custom button of URL type. URL will be
/apex/PageName?id={!Account.Id}
This was selected as the best answer
Max_gMax_g

Thanks for such a quick response.  I greately appreciate that.

 

imutsavimutsav
Yes this is possible. You need to create a new button on Account and in the Behavior select 'display in existing window with sidebar'. content source 'URL'. Now in the body type '/apex/<VFPageName>?id={!Account.Id}

you can also pass more variable values to the VF page by adding '&' after id={!Account.Id}&xyz={!Account.something} ......
In your VF page controller you need to get these values from the Environment variable by using getParameters().

Id acctId = ApexPages.CurrentPage().getParameters().get('id');

let me know if you have any question.

Thanks
Utsav

[Do mark this answer as solution and give Kudos if this helps you resolve the issue]
Max_gMax_g

Thanks for the additional informqation.