buli
2023-07-11 0c4796706fc9473d069b620321a54b20a119906c
force-app/main/default/classes/MetaDataUtility.cls
@@ -1,7 +1,5 @@
public without sharing class MetaDataUtility {
    public static List<Metadata.LayoutSection> GetRecordTypePageLayout(string record_type_id,string objectType){
        Map<string,object> mso = null;
        System.debug('rerord 6' + record_type_id + ':' + objectType);
        string layout_name = GetRecordTypePageLayoutName(record_type_id,objectType,UserInfo.getProfileId());
@@ -16,7 +14,6 @@
                if(c.layoutItems != null && c.layoutItems.size() > 0 ){
                    a = true;
                }
            }
            if(a){
            layoutSectionList.add(section);             
@@ -38,7 +35,6 @@
     */ 
    
    public static string GetTableOrEnumId(string objectType){
        Map<string,object> mso = null;
        string resp = null;
        string table_or_enum_id = objectType;
@@ -66,7 +62,6 @@
        string resp = null;
        Map<string,object> mso = null;
        
        string table_or_enum_id =  GetTableOrEnumId(objectType);
        
        if(string.isBlank(table_or_enum_id)){
@@ -88,13 +83,16 @@
        }
    }
    
    public static string GetRecordTypePageLayoutName(string record_type_id,string objectType, string profile_id){
      System.debug('objectType 92' + objectType);
        System.debug('profile 93 ' + profile_id);
        
        if(!string.isBlank(objectType)){
            List<sobject> lso = [SELECT Id, Name, DeveloperName, SobjectType, IsActive, Description, BusinessProcessId FROM RecordType where SobjectType = :objectType];
            List<sobject> lso = [
                SELECT Id, Name, DeveloperName, SobjectType, IsActive, Description, BusinessProcessId
                FROM RecordType
                WHERE SobjectType = :objectType
            ];
            if(lso.size()==0){
                return string.valueOf(((Map<string,object>)(GetAllPageLayout(objectType)[0])).get('Name'));
            }
@@ -132,13 +130,9 @@
                return null;
            }
        }
    }
    
    public static string ToolingQuery(string query){
        system.debug('query='+query);
        String baseURL = 'callout:SF_Rest_API/services/data/v41.0/tooling/query?q='+ query.replace(' ', '+');
        HttpResponse resp = null;
@@ -162,7 +156,6 @@
            system.debug('status is not ok,error:'+resp.getBody());
            return null;
        }
    }
    
    public static List<Metadata.LayoutSection> GetLayoutSections(string object_name, string layout_name){
@@ -176,10 +169,8 @@
            Metadata.Layout layout = (Metadata.Layout) componentList.get(0);
            List<Metadata.LayoutSection> layoutSectionList = layout.layoutSections;
            return layoutSectionList;
        }
        else{
        } else {
            return null;
        }
    }
}