public without sharing class TestClass { public static List GetLayoutSections(string object_name, string layout_name){ List componentNameList = new List{object_name+'-'+layout_name}; //通过Metadata.Operations.retrieve获取metadata //Metadata.Layout -> Metadata.LayoutSection -> Metadata.LayoutColumn objects -> Metadata.LayoutItem objects List componentList = Metadata.Operations.retrieve(Metadata.MetadataType.Layout, componentNameList); if(componentList?.size() > 0){ Metadata.Layout layout = (Metadata.Layout) componentList.get(0); List layoutSectionList = layout.layoutSections; return layoutSectionList; } else{ return null; } } public static void Foo(){ string query = 'SELECT Layout.Name, Layout.TableEnumOrId, ProfileId, Profile.Name, RecordTypeId FROM ProfileLayout where recordtypeid=\'01210000000QfWdAAK\''; String baseURL = URL.getSalesforceBaseUrl().toExternalForm()+'/services/data/v41.0/tooling/query?q='+ query.replace(' ', '+'); HttpResponse resp = null; HttpRequest req = new HttpRequest(); req.setMethod('GET'); req.setHeader('Authorization', 'Bearer ' + UserInfo.getsessionid()); req.setEndpoint(baseURL); Http client = new Http(); resp = client.send(req); Map mso = (Map)JSON.deserializeUntyped(resp.getBody()); for(string key : mso.keySet()){ system.debug('key='+key); system.debug(mso.get(key)); } mso = (Map)(((List)mso.get('records'))[0]); for(string key : mso.keySet()){ system.debug('key='+key); system.debug(mso.get(key)); } } }