Skip to content

Instantly share code, notes, and snippets.

@charltonAthletic
Last active August 29, 2015 14:16
Show Gist options
  • Save charltonAthletic/b3bca5b4fc2b3a5408b1 to your computer and use it in GitHub Desktop.
Save charltonAthletic/b3bca5b4fc2b3a5408b1 to your computer and use it in GitHub Desktop.
// Custom controller for Visualforce Page - Example 1
// Probably the nicest part of this controller is: 'AND OwnerId = :UserInfo.getUserId'
// which utilizes the getUserId method from the UserInfo class. More info here: salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_userinfo.htm
public class OpportunityRevisitDatesController {
public ApexPages.StandardSetController ssc { // allows us to create list controllers
get {
if(ssc == null) {
ssc = new ApexPages.StandardSetController(Database.getQueryLocator( // instantiate via a query locater
[SELECT Name, Account.Name, Revisit_Date__c FROM Opportunity WHERE Revisit_Date__c <= TODAY AND OwnerId = :UserInfo.getUserId()]));
}
return ssc;
}
set;
}
public List<Opportunity> getOpportunities() { // Method of List collection of sObject Opportunity called getOpportunities
return (List<Opportunity>) ssc.getRecords(); // return List of sObject results from ssc (Standard Set Controller)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment