function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
kumar_arunkumar_arun 

How to query fullName of "Layout" using Tooling Api ?

Hi, everyone
I want to get All Layout of a salesforce org, In that, i also need to get all objects count on which these "Layout". I am using Tooling API to get all "Layout", I get all layout and its count but i am not getting Object Name on which these layout. When i query "fullName" then getting error: -

 [{"message":"An unexpected error occurred. Please include this ErrorId if you contact support: 2083828647-227657 (1162229940)","errorCode":"UNKNOWN_EXCEPTION"}] .

please help.
 
public with sharing class LayoutMetadataCntrl {

    public list<string> LayoutName{get;set;}
    public string TotalLayout{get;set;}
    public LayoutMetadataCntrl (){
        LayoutName=new list<string>();
        TotalLayout='';
        
    }
    public void PageLayout(){
        
         HttpRequest req=new HttpRequest();
        req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
        req.setHeader('content-Type','application/json');
        string domainUrl=URL.getSalesforceBaseUrl().toExternalForm();
        req.setEndpoint(domainUrl+'/services/data/v33.0/tooling/query/?q=Select+id,name,createdDate,fullName+from+Layout');
        req.setMethod('GET');
        Http h=new Http();
        HttpResponse res=h.send(req);
        system.debug(res.getBody());
        
         if(res.getStatusCode()==200){
        
            JsonParser parser=JSON.createParser(res.getBody());
            while(parser.nextToken() !=null){
                if((parser.getCurrentToken()==JSONToken.FIELD_NAME)&& (parser.getText()=='Name')){
                    parser.nextValue();
                    LayoutName.add(parser.getText());
                }
                if((parser.getCurrentToken()==JSONToken.FIELD_NAME)&&(parser.getText()=='Size')){
                parser.nextValue();
                TotalLayout=parser.getText();
                }
             }
           }
    
    }
}

 
Rahul KumarRahul Kumar (Salesforce Developers) 
Hi Kumar,

May I request you to please refer the below link for reference. I hope it will be helpful.

Best Regards
Rahul Kumar
Stanley NgStanley Ng
Did you figure this problem out? I am having the same problem not able to query the FullName from Layout.