I am tryin gto fetch a field value and below is the code,but i am getting below error in SForce
Illegal conversion from List<AggregateResult> to List<String>
public class PickListHandler {
@AuraEnabled
public static List<String> getLevel1(){
List<AggregateResult> groupedLevel1
= [select Level_1__c,COUNT(id) from Case_Type_Data__c group by Level_1__c];
for(AggregateResult ar : groupedLevel1){
System.debug('Level Value Is' + ar.get('Level_1__c'));
}
return groupedLevel1;
}
}
Can some one help in fixing ?
Thanks in advance
Just change your function's returning type to List<AggregateResult> :
public class PickListHandler {
@AuraEnabled
public static List<AggregateResult> getLevel1() {
List<AggregateResult> groupedLevel1 =
[SELECT Level_1__c, COUNT(Id) FROM Case_Type_Data__c GROUP BY Level_1__c];
for(AggregateResult ar : groupedLevel1) {
System.debug('Level Value Is' + ar.get('Level_1__c'));
}
return groupedLevel1;
}
}