0

I have a requirement that needs me to describe a layout on an apex controller, currently I found this Rest Api method that suits my needs: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_sobject_layouts.htm

Is there an apex equivalent method?

And if not how can I call that Api from my apex class, bear in mind that these needs to run in a scheduled method where there is no sessionId

1 Answer 1

3

You can get the details via Metadata API. And in Summer 17 Salesforce released Apex Metadata API. So you can access metadata from your Apex code to access Page layouts.

Example code snippet:

List<String> accLayoutNameList = new List<String>{'Account-Account Layout', 'Account-Account (Sales) Layout'};
List<Metadata.Metadata> components = Metadata.Operations.retrieve(Metadata.MetadataType.Layout, accLayoutNameList);

Metadata.Layout accLayout = (Metadata.Layout) components.get(0);
0

You must log in to answer this question.

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