I need to access the PageLayout NAME assigned for logged in user for a given Object or Record Id. This details needs to be fetched in Lightning component. I think due to security restrictions, Lightning doesn't allow sending HTTP request directly to fetch pageLayout assigned for the logged in user unless we create Connected App, Auth Providers and Named Credential. So I thought of using Metadata API. Is there a way to fetch it using Metadata API? Can I get a code snippet?

1 Answer 1


The API that is intended for this use case is the UI API, which provides support for getting user interface presentation information like the correct layout for a given record and user.

While it's possible to do so with the Metadata API, ordinary unprivileged users can't access the Metadata API at all - it's not easier to authenticate for MDAPI than UI API, it's harder.

Even granting the appropriate permissions, it would involve quite a bit of excess complexity to retrieve the relevant Profile, CustomObject, and PageLayout entities, walk the XML, and generate the proper layout, and the latency of the Metadata API would make performance unacceptable.

  • I need to access the assigned PageLayout Name dynamically for the logged-in user for a given record id / object and record type. Rest of accessing the details of pagelayout is already completed. I don't want to hardcode the details of PageLayout name. May 24, 2019 at 14:29
  • @NoNicknameSFDC I definitely get that, but the Metadata API is not a good solution for you.
    – David Reed
    May 24, 2019 at 14:33
  • Going thru the example here - developer.salesforce.com/docs/atlas.en-us.uiapi.meta/uiapi/… , this works when I am building a custom UI. Even I would agree on this part. My intention is to use Lighting:EditRecordForm with fields loading automatically. Thats the intention behind. With UI API, it becomes too much of code and manual deployments in my case, which would be difficult to convince. May 24, 2019 at 14:49
  • @NoNicknameSFDC It's hard to provide more detail without hearing more about your use case (which is information you can edit into your question). I'm not sure why you need the page layout name alone, or why you would opt not to use <lightning:recordForm>, which does a lot of the heavy lifting for you. Adding this detail to your question can help produce more valid answers.
    – David Reed
    May 24, 2019 at 16:26

You must log in to answer this question.

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