TransWikia.com

Apex Metadata API retrieve PageLayout assigned to Profile

Salesforce Asked by Michael Yocca on November 20, 2021

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”

One Answer

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.

Answered by Bill Appleton on November 20, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP