buli
2023-05-24 1a63180b4cabdf8b63e9a93eab8d715a72a01514
force-app/main/default/classes/LayoutDescriberHelper.cls
@@ -40,7 +40,8 @@
        requiredFieldAPIList = new List<String>();
        fieldAPIToLabelMap = new Map<String,String>();
        layoutSections = new List<LayoutSection>();
        String theRespBody = getLayoutSchema(recordTypeId, objectType,userMode);
        String theRespBody = getLayoutSchema(recordTypeId, objectType,userMode);
        System.debug('theRespBody = ' + theRespBody);
        Map<String, Object> layoutSection = (Map<String, Object>) JSON.deserializeUntyped(theRespBody);
        Map<String,object> m = new Map<String,object>();
        if(String.isBlank(recordTypeId)){
@@ -210,32 +211,23 @@
    }
    public static String getLayoutSchema(Id recordTypeId, String objectType,String userMode){
        System.debug(LoggingLevel.INFO, '*** recordTypeId: ' + recordTypeId);
        System.debug(LoggingLevel.INFO, '*** objectType: ' + objectType);
        System.debug(LoggingLevel.INFO, '*** userMode: ' + userMode);
        String urlPost = '/services/data/v53.0/sobjects/'+objectType+'/describe/layouts/';
        System.debug(LoggingLevel.INFO, '*** urlPost: ' + urlPost);
        if(String.isNotEmpty(recordTypeId) && String.isNotBlank(recordTypeId)){
            urlPost = urlPost + recordTypeId;
        }
        System.debug(LoggingLevel.INFO, '*** urlPost: ' + urlPost);
        String urlForClassic = 'https://'+getUrlPrefix()+urlPost;
        system.debug('URL Post:'+urlForClassic);
        System.debug(LoggingLevel.INFO, '*** UserInfo.getsessionid(): ' + UserInfo.getsessionid());
        System.debug(LoggingLevel.INFO, '*** paramvalue: ' + EncodingUtil.base64Encode(Blob.valueOf(userinfo.getSessionId())));
        HttpResponse resp = null;
        HttpRequest req = new HttpRequest();         
        req.setMethod('GET');        
        if(userMode =='lightning'){
            /*req.setEndPoint('callout:SF_Rest_API'+urlPost);
            system.debug('callout:SF_Rest_API'+urlPost);*/
            req.setEndpoint(urlForClassic);
            req.setHeader('Authorization', 'Bearer ' + UserInfo.getsessionid());
            req.setEndPoint('callout:SF_Rest_API'+urlPost);
            system.debug('callout:SF_Rest_API'+urlPost);
        }else if(userMode == 'classic'){
            req.setEndpoint(urlForClassic); 
            req.setHeader('Authorization', 'Bearer ' + UserInfo.getsessionid());
        }
        System.debug(LoggingLevel.INFO, '*** req: ' + req);
        }
        Http client = new Http();    
        resp = client.send(req);
        system.debug('Schema Body:'+JSON.serialize(resp.getBody()));
@@ -278,7 +270,6 @@
    }
public static Integer ControllerUtil() {
Integer i = 0;
return i;
}