+ Start a Discussion
Shubham MirketaShubham Mirketa 

Assigning dynamic controller to a visualforce page


I want to assign the standard controller to a vf page dynamically. I have a table of records which might be Leads, Accounts or Contacts. There is a view button associated with each record which leads to the standard detail page of the record. Now i want to open it on a vf page but cannot seem to assign the standard controller dynamically since it can either be lead, account or contact, depending upon the type of records in the table. Is there any way to do this? 

Thank You
Hi Shubham,

You cannot assign a controller (standard, extension or a custom controller) to a VF page on the run.

However, your business case can be achieved using a Custom Controller, in which depends on the query string you pass you can identify the Object which you need to process.

One VF page with one custom controller can do this for you.

Hope this helps.