function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
kevincarkevincar 

How to Query using the Salesforce ID object name

Hello all,
I need to find all case objects for a particular contact, but the only constraint that I can see which will give me this is the ContactID.  But when I try to run a query using this field, I get a binding.query exception.
My query statement looks like this:

  Contact sup_Cont = (Contact) mgr_recs[0];
  tmpParentID = sup_Cont.getId();
  strAcctIDsql =  "SELECT ID FROM _case WHERE contactId = '" + tmpParentID.getValue() + "' ";

As an alternative, I guess I couldquery ALL  Case-objects, and then do a string-compare on the ContactID to see if it belongs to a contact, but that just seems stupid.

Anyone have any ideas about what I'm doing wrong?

Thanx!

 

adamgadamg
Looks like "_case" should be "case"..

..i'd also strongly recommend you use the SOQL explorer at sforce.sf.net for building queries - makes debugging these types of issues much easier!