I am trying to get pagelayout assigned to a user by querying ProfileLayout Object. I am running this query.

select Layout.FullName from ProfileLayout where ProfileId='xxxxxxxxxxx' and recordtypeId = 'yyyyyyyyy'

While going through documentation of ProfileLayout Object I found out that enter image description here

only users with "View Setup and Configuration permission" can access this object.

But not all users will have this permission.

Another Issue is If Object doesn't have a recordtype then we need to use TableOrEnumId field to query

select Layout.FullName from ProfileLayout where ProfileId='xxxxxxxxxxx' and TableOrEnumId = 'yyyyyyyyy'

It is mentioned in document that we can use object api name for tableorenumid But api name Doesn't work for custom object and we need get objectId from CustomObject object again using tooling API. This API to get objecteId fails for non-admin users.

Is there any other way to get Pagelayouts assigned to user which should work for all the users.


2 Answers 2


It appears that you're looking for the getRecordCreateDefaults method. This requires no Apex and returns the layout assigned to the user, optionally based on the record type, if specified. From there, you can customize their experience per your business requirements. This uses the UI API, which is accessible to any user that has access to records.


There's no way to do this with native Apex. As you might have guessed or searched, you would need to use the Tooling API and Metadata API to automate this with a callout to your own org endpoints.

On top of that, Page Layouts are associated with profiles only for now (API v58.0), so you would need to associate the page layout with a profile, effectively granting access to that page layout to all users with that profile. This can grow to a problem if you want different users to have different sets of page layouts to them. The number of profiles can grow exponentially that way.

You didn't mention the use case for such automation, but I'd suggest not doing this and find another way to grant access to layouts/permissions. For layouts, you might want to take a look at dynamic layouts on the Lightning App Builder (toggling sections/fields with conditional rendering that can be set up in the UI) and for permissions you can assign permission sets with Apex through the PermissionSet and PermisionSetAssignment objects.

  • I am using tooling api only to get page layouts assigned to a user. Issue that i am facing is that tooling API doesn't work for the users. If we want to query ObjectId from CustomObject using tooling API that doesn't work for non admin users. If i don't have ObjectId i can't query profileLayout object with tooling api. Commented Aug 2, 2023 at 8:33
  • Well, yes. The Tooling API's purpose is to provide a way to progamatically access your org's schema and settings, not to change data in the org. Users' records are considered data, so they are not covered by the Tooling or Metadata APIs. Like I said in my answer post: there's no practical way in doing this. I would suggest you to give up on this requirement, actually. Commented Aug 2, 2023 at 11:58
  • I think there might be some confusion in my question. I am not creating any thing new or assigning any new value. I am just trying to get pagelayout that is assigned to a user for a particular object. My use case is i am overriding NEW button for an object. Then i am opening a LWC page where i am displaying fields based on pagelayout that is assigned to user. I am not using lightning record edit for that because we are not displaying all the fields that are there in page but only few fields based on some logic. Commented Aug 2, 2023 at 15:50
  • I don't get it, you want to know which page layout is assigned to the user, or you want the fields that are to be shown to the user? If it is the latter, you should look up about the UI API. It should return the fields available to the current user for you to build your record page/form the way you need. Maybe you might need to update your original post with the real use case/end result you want with this. Commented Aug 2, 2023 at 16:28

You must log in to answer this question.

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