After including an <apex:relatedList list="Contacts"> in a VisualForce page, is it possible to force the usage of different layout to appear when user click on modify / buttons of this relatedList?

When I mean different layout, I want to force the usage of a different one then the default attributed to the profile.


1 Answer 1


I'd say it would be easier to do away with the apex:detail and use apex:repeat to render your own related list rather than try to override the Edit behaviour.

I reckon the only way to do this would be to override the Edit action on the Contact with a custom Vf page, where you check where the contact edit is being invoked from (using perhaps a url query param) and accordingly redirect to your custom vf page to either the standard or the custom contact edit page.

Note however that overriding the Edit behaviour will mean you can't inline edit Contacts on standard page layouts anymore.

There are of course JavaScript 'hacks' where for eg using Jquery you can replace the HTML rendered behind the button to point to a custom edit page.

You'd still have to build your custom vf page to edit the contact. Or else do RecordType gymnastics to dance to the desired Page Layout assignments.

In summary, I'd think it would be a lot less trouble to render your own related list using apex:repeat

  • And if I fully render the related list in Apex, can I redirect to a custom layout or not? I really need to rebuild all the display of the object in VF?
    – jpmonette
    Commented Nov 17, 2012 at 18:31
  • You can redirect to a custom vf page on click of the Edit link which is built to meet your requirements. Alternatively link invokes a VF page, where the controller updates RecordType such that the assignment changes to your desired layout. Then after save a trigger could restore record type. It is very fidgety :/ unless you have very strong motivations for this behaviour, not recommended. Commented Nov 17, 2012 at 18:56
  • So there's no other way than rebuilding a relationlist look in VisualForce with some Edit / Buttons redirecting to a specific VisualForce page with the fields hardcoded in. Is that what you are saying?
    – jpmonette
    Commented Nov 19, 2012 at 1:47
  • Yes that or the 'RecordType dance' whereby you update the RecordType of the record before redirecting to Edit page and then resetting it back in a before trigger. Not great. Commented Nov 19, 2012 at 9:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .