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
KT@CiscoKT@Cisco 

How to identify case owner as either a User or a Queue

I need to identify for a given case whether the owner of the case is a queue or an agent.

 

When I query the CASE table for OwnerId field, it gives me different string values and I was hoping to identify how to differentiate between whether this OwnerId references a Queue or if it references an agent.

 

Any clues?

 

 

Best Answer chosen by Admin (Salesforce Developers) 
werewolfwerewolf
Well, you could query for Owner.Type.  That'll tell you.

All Answers

werewolfwerewolf
Well, you could query for Owner.Type.  That'll tell you.
This was selected as the best answer
rtuttlertuttle
Any way to do that in a workflow rule?  I've been battling cases that move owners unexpectedly.  The field doesn't seem to be pulled forward for workflow rules to look at.  I thought of using a trigger to add that to a custom field in the case, but seems a bit extreme.  Any ideas?
werewolfwerewolf
I don't think so -- the trigger's the only way.
rtuttlertuttle

Okay new problem with that idea. Everytime I attempt to capture Case.Owner.Type within the trigger on a before insert, before update it shows Owner.Type as null.  Any ideas?

 

 

trigger CaseOwnerTypeTrigger on Case (before insert, before update) { for(Case c : Trigger.new) { c.Owner_Type__c = c.Owner.Type; }}

 

 

werewolfwerewolf
Interesting.  You could use the first 3 chars of OwnerId instead.  If it's an 005 then it's a user, otherwise it's a queue.
rtuttlertuttle

Genius I love it, thanks again.

 

 

For anyone else trying to find the solution, create a field on the case called Owner Type then use the trigger below:

 

 

 

trigger CaseOwnerTypeTrigger on Case (before insert, before update) {

for(Case c : Trigger.new)

{

//c.Owner_Type__c = c.Owner.Type; // won't work, always returns null for some reason

String ownId = c.OwnerId; // necessary to convert ID to string

c.Owner_Type__c = (ownId.substring(0,3) == '005' ? 'User' : 'Queue');

}

}

 

 

Message Edited by rtuttle on 02-25-2009 01:35 PM
Message Edited by rtuttle on 02-25-2009 01:36 PM
Vijay RautVijay Raut

Hi,

 

I understand that, you have workaround to check whether Owner is User or Queue (using first 3 chars). But you have any idea about why "Owner.Type" always returns null? Is it because we are in before trigger context or we need to query for Owner.Type rather than using from Trigger.new as it is not cashed in Trigger.New context variable.

 

Thanks,

V.R. 

werewolfwerewolf
Owner.Type won't work in Trigger.New because Trigger.New doesn't spider to related objects -- you can't get Account.Name there either.  It will only show up if you explicitly query for it.
Vijay RautVijay Raut

Thanks .. I had thought same and that makes sense.

 

Regards,

V.R.

Stephen Johnson 17Stephen Johnson 17
Use the word queue in your queue name. For example, US queue. Use rule or formula etc to look for the word queue.  If owner.name contains 'queue' then...
Lenin Raj 6Lenin Raj 6
Hi,
I have it latest/exact dumps for ADM 201 SU'17. i have passed two days before. if anybody wants contact me leninraj2017@gmail.com. 
Tom Stewart 23Tom Stewart 23
Hi ,

Hi, I have all latest dumps of salesforce for all types of salesforce exams if anyone wants you can mail me at
cloudtutorialstraining@gmail.com

1.Salesforce Administrator (ADM 201)  http://www.latestdumps.net/ADM-201.htm 49$
2.Salesforce DEV-401 Exam  /*Salesforce DEV-401 Braindumps /* http://www.latestdumps.net/DEV-401.htm 49$
3.Salesforce DEV-501 Exam
4. Salesforce Administrator (ADM 211)
5.Salesforce sales cloud

Immediately i will sent dumps latest one,which helps you to pass
cloudtutorialstraining@gmail.com