I have a component that dynamically replicates a page layout . Im querying the ProfileLayout object to get the layout JSON, this works fine when i run as a sys admin, but fails when executed as a non-admin, getting this response:

{"message":"sObject type 'ProfileLayout' is not supported.","errorCode":"INVALID_TYPE"}

this is the query:

string query = 'select Layout.Name from ProfileLayout where ProfileId = \'' + UserInfo.getProfileId() + '\'';

Is there any way to achieve this?

  • 2
    The tooling API is generally unsuitable for non-admins. Perhaps the UI API or REST API would be better suited to your needs?
    – sfdcfox
    Nov 15, 2018 at 15:53
  • I looked at the UI api but there doesn't seem to be a way to get the correct layout for the running user based on Profile/RecordType when creating a new record, its fine for an existing record as i can pass the record ID in
    – paul
    Nov 15, 2018 at 16:03
  • Have you explored the Apex Metadata class? It supports layouts, but I am not sure if it will support your use case. Nov 15, 2018 at 16:22

3 Answers 3


The describe call you're apparently looking for is:


This will give you all the layout information need for a given record type and object type. This call is available for all users so long as they have any API access.


I used by mistake the wrong URL - /data/{apiVersion}/query?q='' instead of /data/{apiVersion}/tooling/query?q='', maybe this also applies to your case.


This works for me:


Notice that the string /tooling is in the URL. Without this bit, it hits the error.

You must log in to answer this question.

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