• Maarten Dun 6
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

Hi all,

 

I'm just wondering if it is possible to use SOQL LIKE with IDs? I tried the following but without any luck.

 

 

List<Case> cases = [SELECT Id FROM Case WHERE Id LIKE '005%'];

 

 

What I'm trying to achieve is to fetch all cases owned by a user (and therefore not a queue). I know I could just fetch all active users and use IN but that would esentially create another query towards the database because I'd first have to fetch the users and then fetch the cases.

 

My current solution is this:

 

 

List<Case> cases = [SELECT Id, OwnerId, Urgent__c FROM Case WHERE (Owner.Profile.Name LIKE '%YFF%' OR Owner.Profile.Name LIKE '%YK%' OR Owner.Profile.Name LIKE '%YO%' OR Owner.Profile.Name LIKE '%YB%') AND OwnerId != '005200000013dtq' AND LastModifiedDate > :lastUpdated AND Reserve_Until__c = null];

 

I'm not too keen on this approach because I'd have to update this SOQL whenever a new profile should be added to the list which brings me back to my initial approach.

 

 

All suggestions are welcome.

 

Cheers.

 

/Søren Nødskov Hansen