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
Shubham MirketaShubham Mirketa 

Assigning dynamic controller to a visualforce page

Hey,

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
LBKLBK
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.