So, currently having an issue using Metadata.Operations.retrieve(Metadata.MetadataType.Layout, _layouts_); in a managed codebase. The object in question is managed and the layouts portion is trying to load (namespace)sObject-Custom Made Layout and it is pulling back null. Whereas if I try (namespace)sObject-(namespace)Made Layout the system will retrieve it as expected.

I have tried the callout in the Dev Console multiple times with differing syntax:

  (namespace)sObject-Custom Made Layout
  sObject-Custom Made Layout
  (namespace)sObject-(namespace)Custom Made Layout

  Even sObject-(namespace)Custom Made Layout

None of the solutions work. Does anyone know of a fix/workaround/issue with this? Or maybe pointing to a known issue/know why it may not be functioning?

  • 1
    I don't understand what your problem is. (namespace)sObject-(namespace)Made Layout is what I would expect to work and you say it does. So why not use it?
    – Keith C
    Jun 25, 2018 at 22:26
  • Correct, if it is a layout made by the package owner it is (namespace)sObject-(namespace)Made Layout but I need to call one made by a user. The call does not work in the contexts I gave above. As I had stated. the (namespace)sObject-(namespace)Made Layout does work as expected. It's trying to call a user made layout inside of a package created object.
    – Brendan
    Jun 26, 2018 at 14:25
  • Oh I see. I would have expected ` (namespace)sObject-Custom Made Layout` to work too. Is "Custom Made Layout" a distinct name compared to "(namespace)Custom Made Layout": for SObject fields accessed from within the package, the namespace version hides the non-namespace version if they are the same ignoring the namespace prefix.
    – Keith C
    Jun 26, 2018 at 14:40
  • You would think that would be the accepted case as (namespace)field__c would be the packaged vs just field__c being user created on a package object is correct. Sadly it does not though.
    – Brendan
    Jun 26, 2018 at 14:46
  • I can confirm the same issue. I don't think the query is unclear. When trying the below query: Metadata.Operations.retrieve(Metadata.MetadataType.Layout, layouts); and layouts is replaced with the below examples, you get mixed results, despite the layouts existing in the org. layouts = Account-Account Layout = Success layouts = pckNamespace__SObject__c-pckNamespace__SObject__c-Layout = Success layouts = pckNamespace__SObject__c-CUSTOM LAYOUT = No results returned.
    – user18961
    Jan 28, 2019 at 23:51


Browse other questions tagged .