3

I'm looking to get the details about the current page layout in Apex. In a custom visualforce page, I'd like to be able to add the "Edit Layout" link that a standard page has and I'd also like to be able to get the details about which related lists are present on the current page layout. I've found some information about calling this through the API, but haven't found anything that works directly in Apex...

4

Page layouts are only available through the Metadata API, which is not available in apex. There is a pretty exhaustive post here on StackExchange and an interesting Github repo for accessing the metadata API from SE superstar Andrew Fawcett:

Has anyone, ever, successfully invoked the Metadata API from within Apex?

|improve this answer|||||
  • Unfortunate. I haven't dealt with anything like this before, so my current barrier to entry is quite high. Any way you could help guide me? – Nathan Williams Oct 16 '13 at 0:19
  • 1
    Honestly, I couldn't since it's not something I've ever attempted – greenstork Oct 16 '13 at 2:49
  • Fair enough, I appreciate the link and confirmation, though! – Nathan Williams Oct 16 '13 at 3:08
  • 1
    Thanks @greenstork for the kind words. :-) Nathan, please take a look at the Retrieve Demo (selecting Layout as the Metadata Type from the dropdown) in the Apex Metadata API library for how to do this. You can deploy the library directly into your org (by clicking the Deploy to Salesforce link in the Readme at the top). github.com/financialforcedev/apex-mdapi#metadata-retrieve-demo – Andrew Fawcett Oct 16 '13 at 8:08

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.