-1

Will the Where in Clause work with a list of Objects? In this case the list holds a list of IDs. Or do I need to cast this List of Objects to the ID datatype before my Dynamic SOQL.

   List<Object> ListOfIDs;

    String query = 'SELECT id FROM Account Where id in :ListOfIDs';

    Database.Query(query);
3

Static and dynamic SOQL need appropriately typed bindings. For this to work you need the "listOfIds" to be one of:

  • List<String>
  • List<Id>
  • or even: List<Account> (where the Account instances include at least the Id field)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.