• ab d
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies
Public Class DynamicController {

    @AuraEnabled
   Public static List<Sobject> getDynamicValues (String recId , string  SobjctNme){
     // String recorId = recId ;
      String SobjectShrNme = SobjctNme ;
       wraperShreLst wrperShrLst = new wraperShreLst ();
       String theQuery ;
     // Public  List<String> accessibleFields = getFieldsList(SobjctNme) ;
       
       if(!SobjectShrNme.endsWith('__c')){
            SobjectShrNme += 'Share' ;  // adding Share to standard object
      
           String sObjId = SobjctNme + 'Id' ; // creating string for sobject id for retrive thier associated share records.
           System.debug('@@@@@@@@@'+sObjId);
         
           theQuery = 'SELECT ' + joinList(getFieldsList(SobjectShrNme) , ', ') +
                          ' FROM ' +SobjectShrNme+ 
                          ' WHERE ' + sObjId + '=\''+recId+'\'';
     System.debug('the query is :'+theQuery);
        
           wrperShrLst.shrlst = Database.query(theQuery) ;
           
            String UsrNme = 'UserorGroup.Name' ; // adding userorgroupName field for feteching name of userorgroup shared list. 
       
           
           
            String thequery1 = 'SELECT '+UsrNme+ ' FROM ' +SobjectShrNme+' WHERE ' + sObjId + '=\''+recId+'\'' ;
                     system.debug('//////////'+thequery1);     
           wrperShrLst.usrGrpLst = Database.query(thequery1);

           system.debug('++++++++++'+wrperShrLst);
          system.debug('@@@@@@@@@@@'+Database.query(theQuery)); // lines added to check
          
       
       }
       else {  // code for getting custom object share records.
          SobjectShrNme = SobjectShrNme.removeEnd('__c') +'__Share' ;  // adding Share to Custom object
          
              String sObjId = 'Parent' + 'Id' ; // creating string for sobject id as parent id for retrive thier associated share records.
           System.debug('@@@@@@@@@'+sObjId);
          
           theQuery = 'SELECT ' + joinList(getFieldsList(SobjectShrNme) , ', ') +  
                          ' FROM ' +SobjectShrNme+ 
                          ' WHERE ' + sObjId + '=\''+recId+'\'';
   
         
           
        List < Sobject > sObjList = Database.query(theQuery) ;
          system.debug('@@@@@@@@@@@'+sObjList); // lines added to check
              
       } 
       return(Database.query(theQuery)); 
   }
    
    Private static List<String> getFieldsList(String   SobjectName){  // Feteching the Fields From Associated Objects.
      
             sObject obj = Schema.getGlobalDescribe().get(SobjectName).newSObject();  // converting String to Sobject.
        
        Map<String, Schema.SobjectField> fields = obj.getSObjectType().getDescribe().fields.getMap();
           List<String > accessibleFields = new List<String>() ; // List of accessibleFields.

        
        for (String s : fields.keySet()) {

            if ( (fields.get(s).getDescribe().isAccessible())) {
   if(s.containsIgnoreCase('Id')|| s.containsIgnoreCase('user') ||  s.containsIgnoreCase('Level') ){ // fields are filter here.

                accessibleFields.add(s); 
   
                    }
            }
        }
       System.debug('+++++++++++++'+accessibleFields);
        String UsrNme = 'UserorGroup.Name' ; // adding userorgroupName field for feteching name of userorgroup shared list. 
        accessibleFields.add(UsrNme);
         return accessibleFields ;
       }

    // Join an Apex List of fields into a SELECT fields list string
    private static String joinList(List<String> theList, String separator) {

        if (theList == null)   { return null; }
        if (separator == null) { separator = ''; }

        String joined = '';
        Boolean firstItem = true;
        for (String item : theList) {
            if(null != item) {
                if(firstItem){ firstItem = false; }
                else { joined += separator; }
                joined += item;
            }
        }
        return joined;
    }
    Public class wraperShreLst {
        @AuraEnabled  Public   List<Sobject> shrlst {get ;set ;} 
        @AuraEnabled   Public  List<sobject> usrGrpLst {get ;set;} 
       
    }
}


in the above highlighted area query is not returning userorGroupName from associates shared object ,
Please Help me to resolve ...
  • February 24, 2018
  • Like
  • 0
Public Class DynamicController {


 @AuraEnabled
   Public static List<Sobject> getDynamicValues (String recId , Sobject  SobjctNme){
     // String recorId = recId ;
      String SobjectNme = String.valueOf(SobjctNme) ;
     // Public  List<String> accessibleFields = getFieldsList(SobjctNme) ;
       
       if(!SobjectNme.endsWith('__c')){
            SobjectNme += 'Share' ;
       }
       else {
          SobjectNme = SobjectNme.removeEnd('__c') +'__Share' ; 
       } 
       
      
   
       String theQuery = 'SELECT ' + joinList(getFieldsList(SobjctNme) , ', ') + 
                          ' FROM ' +  SobjectNme + 
                          ' WHERE Id = :recId';
   
   
          return(Database.query(theQuery)); 
   }
    
    Private static List<String> getFieldsList(Sobject SobjectNme){
      Map<String, Schema.SobjectField> fields = SobjectNme.getSObjectType().getDescribe().fields.getMap();
           List<String > accessibleFields = new List<String>() ;
        for (String s : fields.keySet()) {
            if ( (fields.get(s).getDescribe().isAccessible())) {
                accessibleFields.add(s); 
            }
        }
         return accessibleFields ;
       }

    // Join an Apex List of fields into a SELECT fields list string
    private static String joinList(List<String> theList, String separator) {

        if (theList == null)   { return null; }
        if (separator == null) { separator = ''; }

        String joined = '';
        Boolean firstItem = true;
        for (String item : theList) {
            if(null != item) {
                if(firstItem){ firstItem = false; }
                else { joined += separator; }
                joined += item;
            }
        }
        return joined;
    }
   


Please Help Me...
  • February 17, 2018
  • Like
  • 0
<apex:page contentType="application/vnd.ms-excel">
<analytics:reportChart reportId="00O7F0000068epK" />

</apex:page>

please provide a solution for us.....
  • December 10, 2017
  • Like
  • 0
Public Class DynamicController {


 @AuraEnabled
   Public static List<Sobject> getDynamicValues (String recId , Sobject  SobjctNme){
     // String recorId = recId ;
      String SobjectNme = String.valueOf(SobjctNme) ;
     // Public  List<String> accessibleFields = getFieldsList(SobjctNme) ;
       
       if(!SobjectNme.endsWith('__c')){
            SobjectNme += 'Share' ;
       }
       else {
          SobjectNme = SobjectNme.removeEnd('__c') +'__Share' ; 
       } 
       
      
   
       String theQuery = 'SELECT ' + joinList(getFieldsList(SobjctNme) , ', ') + 
                          ' FROM ' +  SobjectNme + 
                          ' WHERE Id = :recId';
   
   
          return(Database.query(theQuery)); 
   }
    
    Private static List<String> getFieldsList(Sobject SobjectNme){
      Map<String, Schema.SobjectField> fields = SobjectNme.getSObjectType().getDescribe().fields.getMap();
           List<String > accessibleFields = new List<String>() ;
        for (String s : fields.keySet()) {
            if ( (fields.get(s).getDescribe().isAccessible())) {
                accessibleFields.add(s); 
            }
        }
         return accessibleFields ;
       }

    // Join an Apex List of fields into a SELECT fields list string
    private static String joinList(List<String> theList, String separator) {

        if (theList == null)   { return null; }
        if (separator == null) { separator = ''; }

        String joined = '';
        Boolean firstItem = true;
        for (String item : theList) {
            if(null != item) {
                if(firstItem){ firstItem = false; }
                else { joined += separator; }
                joined += item;
            }
        }
        return joined;
    }
   


Please Help Me...
  • February 17, 2018
  • Like
  • 0
I get response as System.HttpResponse[Status=Forbidden, StatusCode=403] when i Quick start with eienstien vision trail