Skip to content

Instantly share code, notes, and snippets.

@lfreeland
Created March 28, 2016 00:52
Show Gist options
  • Save lfreeland/ff7b0ef4de6ed265bad0 to your computer and use it in GitHub Desktop.
Save lfreeland/ff7b0ef4de6ed265bad0 to your computer and use it in GitHub Desktop.
Common Dynamic SOQL
String idInClause = '(\'';
for (Id acctId : accountIds){
idInClause += acctId + ‘\’,\’’;
}
idInClause = idInClause.substring(0,idInClause.length()-2);
idInClause += ')';
String q = 'select id, name from Account where Id in ' + idInClause;
List<Account> accts = Database.query(q);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment