0

Here is my code `

global with sharing class ReportsListController {

   public String dcarr { get; set; }
   public static ReportsColumnMap__c repcols { get; set; }
   public ReportsListController() { } // empty constructor

  @RemoteAction
  global static List<ReportsColumnMap__c> getRepCols(String dcarr) {        
    List<ReportsColumnMap__c> repcols = 
        [SELECT ColumnName__c,SObject__c ,COUNT(ID) FROM ReportsColumnMap__c WHERE ColumnName__c IN ('OWNER','FIRST_NAME','LAST_NAME','TITLE','COMPANY','LEAD_SOURCE','RATING','STREET','EMAIL') AND SObject__c !='null' GROUP BY SObject__c ,ColumnName__c];
    return repcols;
  }
}

`

1

As you are doing Aggregate query so it will result List

List<AggregateResult> repcols = 
        [SELECT ColumnName__c,SObject__c ,COUNT(ID) FROM ReportsColumnMap__c WHERE ColumnName__c IN ('OWNER','FIRST_NAME','LAST_NAME','TITLE','COMPANY','LEAD_SOURCE','RATING','STREET','EMAIL') AND SObject__c !='null' GROUP BY SObject__c ,ColumnName__c];

for (AggregateResult ar : repcols )  {
    System.debug('ColumnName__c' + ar.get('ColumnName__c'));
    System.debug('SObject__c ' + ar.get('SObject__c '));
}

Then you need to create List<ReportsColumnMap__c> and can return it or simple return the List<AggregateResult> repcols

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.