Skip to main content
deleted 138 characters in body
Source Link
SfdcDev14
  • 83
  • 1
  • 4
  • 12

I am trying to display the list returned form this method onto a visualforce page but not having any luck. Any help would be appreciated

public List<Account> accresults {get;set;}

public List<Account> getAccounts(Integer NumberOfRecords){
    List<Account> accountList = [SELECT Id FROM Account where Status__c = 'Open' Limit 5];
    Map<Id, Account> selectedAccountsMap = new map<Id, Account>();
    Account account;
    List<Account>accResults = new List<Account>();
    Integer rand;
    Integer count = accountList.size();
    //Integer numberOfRecordsToSelect = 25;
    Integer i = 1;

    while (i <= NumberOfRecords){
        rand = randomWithLimit(count);
        System.debug('Random Number: ' + rand);
        account = accountList[rand];

        if(selectedAccountsMap.get(account.Id) == null)
        {
            selectedAccountsMap.put(account.Id, account);

            i++;
        }
    }
     
   accresults.addAll(selectedAccountsMap.values());
   system.debug(accresults);
   return accresults;
}

public static Integer randomWithLimit(Integer upperLimit){
    Integer rand = Math.round(Math.random()*1000);
    return Math.mod(rand, upperLimit);
}

I am trying to display the list returned form this method onto a visualforce page but not having any luck. Any help would be appreciated

public List<Account> accresults {get;set;}

public List<Account> getAccounts(Integer NumberOfRecords){
    List<Account> accountList = [SELECT Id FROM Account where Status__c = 'Open' Limit 5];
    Map<Id, Account> selectedAccountsMap = new map<Id, Account>();
    Account account;
    List<Account>accResults = new List<Account>();
    Integer rand;
    Integer count = accountList.size();
    //Integer numberOfRecordsToSelect = 25;
    Integer i = 1;

    while (i <= NumberOfRecords){
        rand = randomWithLimit(count);
        System.debug('Random Number: ' + rand);
        account = accountList[rand];

        if(selectedAccountsMap.get(account.Id) == null)
        {
            selectedAccountsMap.put(account.Id, account);

            i++;
        }
    }
     
   accresults.addAll(selectedAccountsMap.values());
   system.debug(accresults);
   return accresults;
}

public static Integer randomWithLimit(Integer upperLimit){
    Integer rand = Math.round(Math.random()*1000);
    return Math.mod(rand, upperLimit);
}
public List<Account> accresults {get;set;}

public List<Account> getAccounts(Integer NumberOfRecords){
    List<Account> accountList = [SELECT Id FROM Account where Status__c = 'Open' Limit 5];
    Map<Id, Account> selectedAccountsMap = new map<Id, Account>();
    Account account;
    List<Account>accResults = new List<Account>();
    Integer rand;
    Integer count = accountList.size();
    //Integer numberOfRecordsToSelect = 25;
    Integer i = 1;

    while (i <= NumberOfRecords){
        rand = randomWithLimit(count);
        System.debug('Random Number: ' + rand);
        account = accountList[rand];

        if(selectedAccountsMap.get(account.Id) == null)
        {
            selectedAccountsMap.put(account.Id, account);

            i++;
        }
    }
     
   accresults.addAll(selectedAccountsMap.values());
   system.debug(accresults);
   return accresults;
}

public static Integer randomWithLimit(Integer upperLimit){
    Integer rand = Math.round(Math.random()*1000);
    return Math.mod(rand, upperLimit);
}
added 4 characters in body
Source Link
battery.cord
  • 8.9k
  • 8
  • 32
  • 59

I am trying to display the list returned form this method onto a visualforce page but not having any luck. Any help would be appreciated public List accresults {get;set;} public List getAccounts(Integer NumberOfRecords){ List accountList = [SELECT Id FROM Account where Status__c = 'Open' Limit 5]; Map<Id, Account> selectedAccountsMap = new map<Id, Account>(); Account account; ListaccResults = new List(); Integer rand; Integer count = accountList.size(); //Integer numberOfRecordsToSelect = 25; Integer i = 1;

public List<Account> accresults {get;set;}

public List<Account> getAccounts(Integer NumberOfRecords){
    List<Account> accountList = [SELECT Id FROM Account where Status__c = 'Open' Limit 5];
    Map<Id, Account> selectedAccountsMap = new map<Id, Account>();
    Account account;
    List<Account>accResults = new List<Account>();
    Integer rand;
    Integer count = accountList.size();
    //Integer numberOfRecordsToSelect = 25;
    Integer i = 1;

    while (i <= NumberOfRecords){
        rand = randomWithLimit(count);
        System.debug('Random Number: ' + rand);
        account = accountList[rand];

        if(selectedAccountsMap.get(account.Id) == null)
        {
            selectedAccountsMap.put(account.Id, account);

            i++;
        }
    }
     
   accresults.addAll(selectedAccountsMap.values());
   system.debug(accresults);
   return accresults;
}

public static Integer randomWithLimit(Integer upperLimit){
    Integer rand = Math.round(Math.random()*1000);
    return Math.mod(rand, upperLimit);
}

I am trying to display the list returned form this method onto a visualforce page but not having any luck. Any help would be appreciated public List accresults {get;set;} public List getAccounts(Integer NumberOfRecords){ List accountList = [SELECT Id FROM Account where Status__c = 'Open' Limit 5]; Map<Id, Account> selectedAccountsMap = new map<Id, Account>(); Account account; ListaccResults = new List(); Integer rand; Integer count = accountList.size(); //Integer numberOfRecordsToSelect = 25; Integer i = 1;

    while (i <= NumberOfRecords){
        rand = randomWithLimit(count);
        System.debug('Random Number: ' + rand);
        account = accountList[rand];

        if(selectedAccountsMap.get(account.Id) == null)
        {
            selectedAccountsMap.put(account.Id, account);

            i++;
        }
    }
     
   accresults.addAll(selectedAccountsMap.values());
   system.debug(accresults);
   return accresults;
}

public static Integer randomWithLimit(Integer upperLimit){
    Integer rand = Math.round(Math.random()*1000);
    return Math.mod(rand, upperLimit);
}

I am trying to display the list returned form this method onto a visualforce page but not having any luck. Any help would be appreciated

public List<Account> accresults {get;set;}

public List<Account> getAccounts(Integer NumberOfRecords){
    List<Account> accountList = [SELECT Id FROM Account where Status__c = 'Open' Limit 5];
    Map<Id, Account> selectedAccountsMap = new map<Id, Account>();
    Account account;
    List<Account>accResults = new List<Account>();
    Integer rand;
    Integer count = accountList.size();
    //Integer numberOfRecordsToSelect = 25;
    Integer i = 1;

    while (i <= NumberOfRecords){
        rand = randomWithLimit(count);
        System.debug('Random Number: ' + rand);
        account = accountList[rand];

        if(selectedAccountsMap.get(account.Id) == null)
        {
            selectedAccountsMap.put(account.Id, account);

            i++;
        }
    }
     
   accresults.addAll(selectedAccountsMap.values());
   system.debug(accresults);
   return accresults;
}

public static Integer randomWithLimit(Integer upperLimit){
    Integer rand = Math.round(Math.random()*1000);
    return Math.mod(rand, upperLimit);
}
added 52 characters in body
Source Link
SfdcDev14
  • 83
  • 1
  • 4
  • 12

I am trying to display the list returned form this method onto a visualforce page but not having any luck. Any help would be appreciated public List accresults {get;set;} public List getAccounts(Integer NumberOfRecords){ List accountList = [SELECT Id FROM Account where Status__c = 'Open' Limit 5]; Map<Id, Account> selectedAccountsMap = new map<Id, Account>(); Account account; ListaccResults = new List(); Integer rand; Integer count = accountList.size(); //Integer numberOfRecordsToSelect = 25; Integer i = 1;

public List<Account> getAccounts(Integer NumberOfRecords){
    List<Account> accountList = [SELECT Id FROM Account where Status__c = 'Open' Limit 5];
    Map<Id, Account> selectedAccountsMap = new map<Id, Account>();
    Account account;
    List<Account>accResults = new List<Account>();
    Integer rand;
    Integer count = accountList.size();
    //Integer numberOfRecordsToSelect = 25;
    Integer i = 1;

    while (i <= NumberOfRecords){
        rand = randomWithLimit(count);
        System.debug('Random Number: ' + rand);
        account = accountList[rand];

        if(selectedAccountsMap.get(account.Id) == null)
        {
            selectedAccountsMap.put(account.Id, account);

            i++;
        }
    }
     
   accresults.addAll(selectedAccountsMap.values());
   system.debug(accresults);
   return null;accresults;
}

public static Integer randomWithLimit(Integer upperLimit){
    Integer rand = Math.round(Math.random()*1000);
    return Math.mod(rand, upperLimit);
}

I am trying to display the list returned form this method onto a visualforce page but not having any luck. Any help would be appreciated

public List<Account> getAccounts(Integer NumberOfRecords){
    List<Account> accountList = [SELECT Id FROM Account where Status__c = 'Open' Limit 5];
    Map<Id, Account> selectedAccountsMap = new map<Id, Account>();
    Account account;
    List<Account>accResults = new List<Account>();
    Integer rand;
    Integer count = accountList.size();
    //Integer numberOfRecordsToSelect = 25;
    Integer i = 1;

    while (i <= NumberOfRecords){
        rand = randomWithLimit(count);
        System.debug('Random Number: ' + rand);
        account = accountList[rand];

        if(selectedAccountsMap.get(account.Id) == null)
        {
            selectedAccountsMap.put(account.Id, account);

            i++;
        }
    }
     
   accresults.addAll(selectedAccountsMap.values());
   system.debug(accresults);
   return null;
}

public static Integer randomWithLimit(Integer upperLimit){
    Integer rand = Math.round(Math.random()*1000);
    return Math.mod(rand, upperLimit);
}

I am trying to display the list returned form this method onto a visualforce page but not having any luck. Any help would be appreciated public List accresults {get;set;} public List getAccounts(Integer NumberOfRecords){ List accountList = [SELECT Id FROM Account where Status__c = 'Open' Limit 5]; Map<Id, Account> selectedAccountsMap = new map<Id, Account>(); Account account; ListaccResults = new List(); Integer rand; Integer count = accountList.size(); //Integer numberOfRecordsToSelect = 25; Integer i = 1;

    while (i <= NumberOfRecords){
        rand = randomWithLimit(count);
        System.debug('Random Number: ' + rand);
        account = accountList[rand];

        if(selectedAccountsMap.get(account.Id) == null)
        {
            selectedAccountsMap.put(account.Id, account);

            i++;
        }
    }
     
   accresults.addAll(selectedAccountsMap.values());
   system.debug(accresults);
   return accresults;
}

public static Integer randomWithLimit(Integer upperLimit){
    Integer rand = Math.round(Math.random()*1000);
    return Math.mod(rand, upperLimit);
}
Made indentation of provided code consistent
Source Link
Derek F
  • 64k
  • 15
  • 54
  • 104
Loading
added 52 characters in body
Source Link
SfdcDev14
  • 83
  • 1
  • 4
  • 12
Loading
Source Link
SfdcDev14
  • 83
  • 1
  • 4
  • 12
Loading