You need to sign in to do that
Don't have an account?
GordymanLG2
SOQL Query to SELECT Cases owned by a Queue
Why won't this SOQL query work?
Case tmpCase = [select Id from Case where IsClosed = true and OwnerId like '00G' limit 1];
I am trying to get a particular type of Case in a test class. The compiler complains whenever I put in the LIKE expression.
If this won't work, any suggestions on how to do it?
Thanks.
I thought about but it was more complexity than I wanted in a test class. If there was some easy way to query up all the queue ID without running into return record limits, then I might have considered it. But I didn't want to embed IDs in classes if I can avoid it. This Production org is always getting refreshed to sandboxes for dev work and it's already painful to modify if we actually want a working environment to test in. And then you have to re-edit them manually to redeploy to production. Just not worth it.
Thanks for the confirmation that LIKE can't be used with IDs. How did you find that out? I scoured all the documentation and nothing like that ever showed up. You think for a company that wants to make the Force.com platform the global standard, they would understand that accurate and timely information that is of use to developers and integrators would save them a ton of trouble and buy them a lot of goodwill. SFDC documentation is real pretty second class in a lot of areas. IMHO, of course. :smileyvery-happy:
All Answers
You cannot use LIKE operator with ID fields. You will have to potentially build a list<ID> of all the queue ids that you are interested in and then use an IN clause.
I thought about but it was more complexity than I wanted in a test class. If there was some easy way to query up all the queue ID without running into return record limits, then I might have considered it. But I didn't want to embed IDs in classes if I can avoid it. This Production org is always getting refreshed to sandboxes for dev work and it's already painful to modify if we actually want a working environment to test in. And then you have to re-edit them manually to redeploy to production. Just not worth it.
Thanks for the confirmation that LIKE can't be used with IDs. How did you find that out? I scoured all the documentation and nothing like that ever showed up. You think for a company that wants to make the Force.com platform the global standard, they would understand that accurate and timely information that is of use to developers and integrators would save them a ton of trouble and buy them a lot of goodwill. SFDC documentation is real pretty second class in a lot of areas. IMHO, of course. :smileyvery-happy:
You could store the Queue Id or Ids that you are looking for in a "Custom Setting". This helps externalize your ids from the Apex code and make it easier make changes specific to an environment.