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
parkerAPTparkerAPT 

How to redirect record views w/ URL (.salesforce.com/[RECORD_ID]) to custom Apex Page?

Is there a way to redirect or override the default record view for standard sObjects?

For example, if a user was visiting: cs1.salesforce.com/003S0000002Wagt, they normally see the Standard Contact view.  This also works for any record type, it seems that the first 3 characters determine the type of sObject and appropriately display the view.


I have written a custom Apex page for the Contact view and would like to have this be the default view that everyone sees when navigating to the page for a specified Contact Record.  I know that I can customize the page layout of the standard view but am having difficultly figuring out how to redirect to my custom page.

Ideally, for the above link, the user should be redirected to something like: salesforce.com/apex/CustomView?cid=003S0000002Wagt

Can someone point me in the right direction please?

Thanks
Parker
jwetzlerjwetzler
Have you been through the developer guide?  If your page uses the standard controller for the object you're intending to override (you can use extensions to add in your custom logic if you need more functionality than what the standard controller gives you) then that page is available for overriding the object view in the Buttons and Links section in setup.
parkerAPTparkerAPT
Ahh... that's where it lives.

I had looked but couldn't find a good reference in the documentation. Looking back through the documentation, it looks like only in the Standard List controller is there any reference to overriding the standard buttons and links. I guess I didn't realized "Buttons and Links" included the ability to change the default "View" for each object.

Regardless, thanks for the tip and advice.

Another question:
It looks like you cannot override the default Activity History View just as you cannot create a Standard List Controller for ActivityHistory.

In order to redirect to my custom Activity History View, it looks like I have to override the "View All" button with a custom s-Control.

Is this indeed the case? If so, are there plans to expand the Standard List Controller to ActivityHistory?

Thanks
Parker
jwetzlerjwetzler
I'll send your question on to our product owner but I think you're correct.  Activities are a special beast because they involve both tasks and events.

The overall goal is that you will be able to use Visualforce anywhere you can use s-controls today, so I think you're right about that as well.