I'm not able to get past what looks like a simple query in Apex and SOQL. I'm trying to query on an Id and I've tried many things. The query is built up dynamically using strings and the final part in this format works fine when hardcoding and Id:
String queryPt2 = ' From Contact Where Id = \'1035U00000ckdinQAX\'';
When using this final segment, everything works fine, but this is processing a single Id, which is of course not what we want, so we're trying this:
String queryPt2 = ' From Contact Where Id = :conId';
Where "conId" is passed through an Apex method. When using this technique, the query doesn't catch and returns null.
I have tried passing the Id as and Id and as a String, passing it as a String and converting to an Id, passing as an Id and converting it to a String and nothing has so far worked except hard-coding it in the format above. I'm thinking that it's some kind of formatting issue and the query itself seems to work because hard coding an Id returns the correct data.
Any thoughts would be appreciated!