1

I know it's possible to retrieve page layout metadata natively from Salesforce however I'm trying to grab the page layout assigned to a particular profile and in order to do that I need to grab the Profile/ProfileLayout.

Ex. To grab metadata info on the page layout I pass in.

List<Metadata.Metadata> layouts = 
Metadata.Operations.retrieve(Metadata.metadataType.Layout, 
                             new List<String> {'Account-Account Layout'});

My question is how to I do this for Profile/ProfileLayout/ProfileLayoutAssignments "Natively in Salesforce"

  • 4
    Have you considered the User Interface API instead? – Adrian Larson Jul 27 '18 at 21:40
  • Yeah I'm not trying to make it more complicated than it needs to be. I need to create a viable replacement for a detail page layout in Lightning Experience and want to grab the running user's assigned layout instead of statically setting it. – Michael Yocca Jul 27 '18 at 21:52
  • 1
    @MichaelYocca That's the explicit purpose of the UI API. Your objective is pretty much its designed-in use case, and the Lightning Experience uses it for that purpose. – David Reed Jul 27 '18 at 22:12
  • Yeah I realize it is the use case of the UI API but seems somewhat overkill since my solution is residing in lightning and not on a external web application. I can accomplish what I am trying to do already I just don't want to statically set the page layout to grab the sections/fields from – Michael Yocca Jul 27 '18 at 22:14
  • @DavidReed I gave it a try and the UI API was pretty simple to setup and play around with. Thank you! Adrian Larson Thank you as well – Michael Yocca Jul 28 '18 at 22:39
0

First, use the Metadata API to Retrieve() the desired Profile. Look in the Profile XML file for the layoutAssignments element. It will look something like this:

<layoutAssignments>
    <layout>object-layout</layout>
    <recordType>object.recordtype</recordType>
</layoutAssignments>

This defines the junction between the object, record type, and layout for that profile. You can find the given layout with another Retrieve() call. Hope that helps.

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.