0

On Mini Layout we have Fields & RelatedList, I want to ask on how we can get/Query the Selected Fields for an Object on Mini Layout Page in the Apex Class?

I am using the following code snippet, is it a right way to do so?

List<Metadata.CustomMetadataValue> values = customMetadataRecord.values; List<Metadata.Metadata> layouts = Metadata.Operations.retrieve(Metadata.MetadataType.Layout, new List {'PurchaseOrder__c-Purchase Order Layout'});

Metadata.Layout layoutMd = (Metadata.Layout)layouts.get(0);
Metadata.MiniLayout mini_layout = layoutMd.minilayout;

3
  • Hi and welcome to SFSE. You did not attach the screenshot. Additionally, your question is a bit light on detail. I suggest you read how to ask then edit your question to add more detail.
    – Phil W
    Jan 29 at 8:49
  • Hi. You should edit the question to add this code example (and your screenshot).
    – Phil W
    Jan 29 at 10:57
  • I looked at trying to get the mini layout details last year for a requirement and concluded that it isn't possible.
    – Phil W
    Jan 29 at 10:58
0

If this is possible for your case, I would advice you to go with an object Field set, which is made for use in APEX:

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_fieldsets_describe.htm

https://developer.salesforce.com/forums/?id=906F0000000MKkCIAW#:~:text=Hello%20Sandeep%2C-,A%20field%20set%20is%20a%20grouping%20of%20fields.,its%20fields%20and%20render%20them.

Please give me feedback if this would help you, if not I would try to give more details.

1
  • I am using the following code snippet, is it a right way to do so? List<Metadata.CustomMetadataValue> values = customMetadataRecord.values; List<Metadata.Metadata> layouts = Metadata.Operations.retrieve(Metadata.MetadataType.Layout, new List<String> {'PurchaseOrder__c-Purchase Order Layout'}); Metadata.Layout layoutMd = (Metadata.Layout)layouts.get(0); Metadata.MiniLayout mini_layout = layoutMd.minilayout;
    – ImNoob
    Jan 29 at 10:38

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.