I am trying to get compact layouts using metatadataapi. I am using https://github.com/financialforcedev/apex-mdapi/blob/master/apex-mdapi/src/classes/MetadataServiceExamples.cls this repo to get Compact Layouts.
I have written a following code to get compact layout.
MetadataService.MetadataPort metadata = MetadataService.createService();
MetadataService.CompactLayout cl = (MetadataService.CompactLayout) metadata.readMetadata('CompactLayout', new String[] { 'Contact-APINameForCompactLayout' }).getRecords()[0];
system.debug(cl);
But in response I am getting following response
CompactLayout:[Metadata.fullName=null, apex_schema_type_info=(http://soap.sforce.com/2006/04/metadata, true, false), field_order_type_info=(fullName, fields, label), fields=null, fields_type_info=(fields, http://soap.sforce.com/2006/04/metadata, null, 0, -1, false), fullName=null, fullName_type_info=(fullName, http://soap.sforce.com/2006/04/metadata, null, 0, 1, false), label=null, label_type_info=(label, http://soap.sforce.com/2006/04/metadata, null, 1, 1, false), type=CompactLayout, type_att_info=(xsi:type)]
I have tried different name combination for in
new String[] { 'Contact-APINameForCompactLayout' }
I have tried
- ObjectName-APINameForCompactLayout
- ObjectName.APINameForCompactLayout
- ObjectName.LabelForCompactLayout
- ObjectName-LabelForCompactLayout
- ObjectName-recordTypeName
- ObjectName.recordTypeName
But nothing in working.
I also looked into metadata namespace that works for apex natively for metadata operations. Is there an apex function that replicates the Describe Layouts Rest Api call But it only works for Layouts not compactLayouts.
What am I missing here?How I can get compactLayouts using Metadata API?