1

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.

Thanks.

2

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 Nov 17 '12 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. – techtrekker Nov 17 '12 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 Nov 19 '12 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. – techtrekker Nov 19 '12 at 9:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.