• Sneha Mogali
  • NEWBIE
  • 20 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Hi, 
I got the above error while trying to "Create an Indicator Badge Apex Service "
And the code of INDICATOR_Controller  shown as below 
public class INDICATOR_Controller {
    private static SObject sobj;
    @AuraEnabled
    public static String getSObjectLabel(String sObjName){
        String label = Schema.getGlobalDescribe().get(sObjName).getDescribe().getLabel();
        return label;
    }
    @AuraEnabled
    public static List<INDICATOR_Service.Indicator> getIndicators(String recId, String objectName){
        getSObject(recId, objectName);
        if(sobj != NULL){
            List<INDICATOR_Service.Indicator> indicators = INDICATOR_Service.getIndicatorBadgesForObject(sobj);
            return indicators;
        } else{
            return null;
        }
    }
    public static void getSObject(String recId, String objectName){
        List<String> fNames = INDICATOR_Service.getFieldsToQueryForObject(objectName);
        if(fNames.size() > 0){
            String query = 'SELECT Id,'+ String.join(fNames,',')+' FROM '+ objectName +' WHERE Id =\''+ recId +'\' LIMIT 1';
            List<SObject> results = Database.query(query);
            if(results.size() == 1){
                sobj = results[0];
            }
        }
    }
}

Please Help!

Thanks,
Sneha M.
Hi, 
I got the above error while trying to "Create an Indicator Badge Apex Service "
And the code of INDICATOR_Controller  shown as below 
public class INDICATOR_Controller {
    private static SObject sobj;
    @AuraEnabled
    public static String getSObjectLabel(String sObjName){
        String label = Schema.getGlobalDescribe().get(sObjName).getDescribe().getLabel();
        return label;
    }
    @AuraEnabled
    public static List<INDICATOR_Service.Indicator> getIndicators(String recId, String objectName){
        getSObject(recId, objectName);
        if(sobj != NULL){
            List<INDICATOR_Service.Indicator> indicators = INDICATOR_Service.getIndicatorBadgesForObject(sobj);
            return indicators;
        } else{
            return null;
        }
    }
    public static void getSObject(String recId, String objectName){
        List<String> fNames = INDICATOR_Service.getFieldsToQueryForObject(objectName);
        if(fNames.size() > 0){
            String query = 'SELECT Id,'+ String.join(fNames,',')+' FROM '+ objectName +' WHERE Id =\''+ recId +'\' LIMIT 1';
            List<SObject> results = Database.query(query);
            if(results.size() == 1){
                sobj = results[0];
            }
        }
    }
}

Please Help!

Thanks,
Sneha M.