2

I have seen the answer to this post: Retrieving Packaged Page Layout in Apex I am using the same code with my values substituted:

List<String> componentNameList = new List<String>{'MyNamespace__Transaction__c-MyNameSpace__Transaction Layout'};
List<Metadata.Metadata> components = Metadata.Operations.retrieve(Metadata.MetadataType.Layout, componentNameList);
Metadata.Layout layout = (Metadata.Layout) components.get(0);
System.debug(layout);

I can retrieve a Page Layout for Standard sObjects like Account and Opportunity. I can retrieve a Page Layout for a Managed Object for a Page Layout that was included with the Package. Where I am hitting an issue is retrieving a Page Layout for the same Managed object and a Layout that was created custom in the SFDC Org.

My Page Layout Name on the Managed sObject from workbench is 'MyCustom Layout'. I have tried using 'MyNamespace__Transaction__c-MyNameSpace__MyCustom Layout' and 'MyNamespace__Transaction__c-MyCustom Layout' as the value to retrieve the metadata but neither works.

Anyone have any suggestions on how to retrieve a Custom Page Layout from a Managed sObject?

2 Answers 2

3

Use ManagedPackageNameSpace__CustomObject__c-MyNamespace__MyCustom Layout to retrive custom layout for a managed object.

8
  • I tried that also and the page layout was not retrieved. It appears to be a bug. Commented Oct 19, 2018 at 14:21
  • Can you please text here, what exactly you have tried? Commented Oct 19, 2018 at 14:28
  • @myForceDotCom Are you trying to get the layout from a dev org where your installed the managed package and your page layout is created locally (not with the namespace) or are you working on a namespaced scratch org?
    – Ranga
    Commented Oct 19, 2018 at 14:32
  • I am working in a Production Org with the managed Package installed. Commented Oct 19, 2018 at 14:34
  • This code returns the Managed Page Layout: componentNameList.add('litify_pm__Matter__c-litify_pm__Matter Layout v3'); These do not. PersonalNuggets is the Custom Page Layout created custom in the org. componentNameList.add('litify_pm__Matter__c-PersonalNuggets'); componentNameList.add('litify_pm__Matter__c-litify_pm__PersonalNuggets'); Commented Oct 19, 2018 at 14:41
2

After countless variations it appears to be a known issue. https://success.salesforce.com/issues_view?id=a1p3A0000008fw0QAA&title=unable-to-retrieve-unmanaged-layout-of-managed-object-via-metadate-api

You must log in to answer this question.

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