Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Apex class to retrieve cases, accounts and their status
global without sharing class LCC_CaseResults {
public static List<CaseViewResults> getAllCases() {
LIST<Case> filteredCases = new LIST<Case>();
LIST<Account> filteredAccounts = new LIST<Account>();
LIST<CaseViewResults> results = new LIST<CaseViewResults>();
Map<String, Case> recordSet = new Map<String, Case>();
SET<String> accountIds = new SET<String>();
//Query to retrieve your cases
//PS: This is a generic query and you can filter it based on your requirement
filteredCases = [SELECT Id, CaseNumber, toLabel(Status), Account.Name, AccountId from Case
where AccountId!='' LIMIT 999];
for(Case record : filteredCases) {
recordSet.put(, record);
system.debug('Accounts are:::'+accountIds);
filteredAccounts =[Select id, name from account where id IN:accountIds LIMIT 2];
filteredCases = new LIST<Case>();
CaseViewResults record = new CaseViewResults();
record.cases = filteredCases;
record.accounts = filteredAccounts;
return results;
//Wrapper class
public class CaseViewResults {
@AuraEnabled public LIST<Account> accounts;
@AuraEnabled public LIST<Case> cases;
public CaseViewResults() {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment