Activity Forums Salesforce® Discussions How to get know the OwnerType of a case is Queue in Salesforce apex?

  • Yogesh

    Member
    December 4, 2019 at 8:20 am

    Hello,

    you can check

    if(string.valueOf(c.OwnerId).startsWith('005'))
    {
    //owner is User
    }

    if(string.valueOf(c.OwnerId).startsWith('00G'))
    {
    //owner is Queue
    }

    This can save you a SOQL 🙂 and is standard across all ORGS in salesforce

    if our suggestion(s) worked,  let us know by marking the answer as "Best Answer" right under the comment.This will help the rest of the community should they have a similar issue in the future.

    Thank you!

  • Deepak

    Member
    December 4, 2019 at 2:34 pm

    Query the case owner as it is a user then query usertype of that user.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos

How to Learn Salesforce Development | Salesforce learning steps for beginners | Trailhead demo

Video in

In this video, we shared the steps to learn salesforce lightning basics, salesforce apex development, CRM in online for free from scratch very quickly. Learn salesforce…