You need to sign in to do that
Don't have an account?
Palash Rana 8
How to Display List of Aggregated result via workbench
I want to display List of Aggregated result i.e Id,Name, Count,but cant get it as i get Null Id iall the retrived records
@RestResource(urlMapping='/GetDuplicateReord/*') global class duplicateRecords { @HttpGet global static List<AccountInfo> getRecords(){ RestRequest req = RestContext.request; RestResponse res = RestContext.response; res.addHeader('Content-Type', 'application/json'); List<AggregateResult> account=[SELECT Name,Prospect_Code__c , Count(id) ids FROM Account where Id Not In (Select AccountId from Contact) And Id Not In (Select AccountId from Opportunity) GROUP BY Name, Prospect_Code__c HAVING count(Id)>1]; List<AccountInfo> r_accounts = new List<AccountInfo>(); for(AggregateResult acc:account){ AccountInfo racc_info = new AccountInfo(); racc_info.Id=acc.Id; //racc_info.Name=acc.Name; //racc_info.prospectCode=acc.prospectCode; r_accounts.add(racc_info); } return r_accounts; } global class AccountInfo{ String Id; String Name; // String prospectCode; } }
And not it is getting me the result i needed
Below is the code