Skip to content

Instantly share code, notes, and snippets.

@forcementor
Created October 22, 2012 00:33
Show Gist options
  • Save forcementor/3929080 to your computer and use it in GitHub Desktop.
Save forcementor/3929080 to your computer and use it in GitHub Desktop.
Developing Mobile…Force.com and Sencha-Part 3, Step 2: Lookback at Query() on Apex controller
@RemoteAction
public static Response Query(QueryRequest qr) {
Response resp = new Response();
List < Lead > LeadList;
filterString = qr.searchFilter;
try {
//Fetch all Leads for the user
LeadList = getAllLeads();
} catch (Exception e) {
resp.success = false;
resp.errorMessage = 'Query failed: ' + e.getMessage();
return resp;
}
//Supply only the requested records
for (Integer recno = qr.start; recno < (qr.start + qr.recordCount) && recno < LeadList.size(); ++recno) {
resp.records.add(LeadList[recno]);
}
resp.total = LeadList.size();
resp.success = true;
return resp;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment