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
JaiJai 

Please help me below situation

I have a requirement to check if Case Owner ID is any Queue Id then change the Flag value to True.

I am strucked here how to compare Case Owner Id with List of Queue Id's.

Thanks!!
Best Answer chosen by Jai
Shiraz HodaShiraz Hoda
Hi Jai,

Please use below code to resolve your issue:
boolean flag = false;
if(case.ownerId.startsWith('005')){
//do nothing
}else if(case.ownerId.startsWith('00G')){
Flag = true;
}
If this solves your issue, Kindly mark this as best answer.
​​​​​​​
Regards,
SHiraz​​​​​​​
 

All Answers

Sai PraveenSai Praveen (Salesforce Developers) 
Hi,

The Queue Id start with 00G so simply you can check if the owner is staring with 00G or not and by this you can conculde if the owner is Queue or user.

Please find the below solution (https://www.biswajeetsamal.com/blog/check-case-owner-is-a-user-or-queue/) for the same.

Let me know if you face any issues.

If this solution helps, Please mark it as best answer.

Thank
Shiraz HodaShiraz Hoda
Hi Jai,

Please use below code to resolve your issue:
boolean flag = false;
if(case.ownerId.startsWith('005')){
//do nothing
}else if(case.ownerId.startsWith('00G')){
Flag = true;
}
If this solves your issue, Kindly mark this as best answer.
​​​​​​​
Regards,
SHiraz​​​​​​​
 
This was selected as the best answer
CharuDuttCharuDutt
Hii Jai
Try Below Trigger
Trigger CaseOwnerOn Case(Before Insert,Before Update){
 if(trigger.IsBefore){
  If(trigger.IsInsert){
   for(case oCase : trigger.new){
     string sCaseOwnerId = case.ownerId;
    if(sCaseOwnerId .startsWith('00G')){
     oCase.Flage__c = true;
    }else{
     oCase.Flage__c = false;
    }
   }
  }
  if(trigger.IsUpdate){
   for(case oCase : trigger.new){
    if(oCase.OwnerId != trigger.oldmap.get(oCas.Id).OwnerId){
      string sCaseOwnerId = case.ownerId;
     if(sCaseOwnerId .startsWith('00G')){
      oCase.Flage__c = true;
     }else{
      oCase.Flage__c = false;
     }
    }
   }
  }
 }
}
Please Mark It As Best Asnwer If It Helps
Thank You!