Skip to content

Commit

Permalink
Only add Id to list of fields to be retrieved if it is not already there
Browse files Browse the repository at this point in the history
  • Loading branch information
Pat Patterson committed Oct 1, 2012
1 parent 774a837 commit 4cf5648
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions RemoteTKController.cls
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,20 @@ public class RemoteTKController {

@remoteAction
public static String retrieve(String objtype, String id, String fieldlist) {
// TODO - handle missing fieldlist - retrieve all fields
String fieldString = '';
// TODO - handle null fieldlist - retrieve all fields
Boolean containsId = false;
for (String field : fieldlist.split(',')) {
fieldString += ','+field;
if (field.equalsIgnoreCase('id')){
containsId = true;
break;
}
}

if (!containsId) {
fieldlist = 'Id,'+fieldlist;
}

String soql = 'SELECT Id'+fieldString+' FROM '+objtype+' WHERE Id = \''+id+'\'';
String soql = 'SELECT '+fieldlist+' FROM '+objtype+' WHERE Id = \''+id+'\'';
List<sObject> records;
try {
records = Database.query(soql);
Expand Down

0 comments on commit 4cf5648

Please sign in to comment.