function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
PascalPascal 

How Can I Compact This Code?

Map<Id,String> userEmail = new Map<Id, String>{};
    List<User> userList = [SELECT Id, Email FROM User WHERE IsActive = TRUE];
    Map<Id, String> acctMap = new Map<Id, String>{};
    List<Account> acctList = [SELECT Id, Tech_Rep_Mgr__c FROM Account];
    for(User u : userList){
        userEmail.put(u.Id, u.Email);
    }
    for(Account a : acctList){
        acctMap.put(a.Id, a.Tech_Rep_Mgr__c);
    }
SrikanthKuruvaSrikanthKuruva
for a given transaction yo ucannot query more than 50,000 records. you might want to put a limit there. if you can try explaining what you are trying to achieve i might sugges something better. below is something which you can try as of now[you dont need the list variables].

    Map<Id,String> userEmail = new Map<Id, String>{};
    Map<Id, String> acctMap = new Map<Id, String>{};
    for(User u : [SELECT Id, Email FROM User WHERE IsActive = TRUE]){
        userEmail.put(u.Id, u.Email);
    }
    for(Account a : [SELECT Id, Tech_Rep_Mgr__c FROM Account]){
        acctMap.put(a.Id, a.Tech_Rep_Mgr__c);
    }