You need to sign in to do that
Don't have an account?
Ross James
If an Owner is a User or a Queue - a Lead Trigger
I have a simple trigger on Leads that needs to know if the Owner is a User or a Queue.
Can anyone show me the (proably very) simple solution to this? My code is below, with the 'real world' question if Owner = Queue.
Set<id> ownerIds = new Set<id>(); for (Lead l : Trigger.new) ownerIds.add(l.OwnerId); Map<id, User> owners = new Map<id, User>([Select Id from User Where Id in :ownerIds]); for (Lead l : Trigger.new) if(l.Owner = queue){ //l.Owner_Usable__c = null; } else { //l.Owner_Usable__c = owners.get(l.OwnerId).Id; }
try adding an extra = sign for comparison. One = is for assignment.
if Owner = Queue is just the question I am asking - I have no idea how to approach asking the IF Statement about Users and Queues.
Hey you can do query on group object.
Select g.Type, g.OwnerId, g.Name,g.id From Group g where type= 'queue'
I'm having the same problem. One thing we can check is the prefix of the OwnerId. If this is 00G then it is a queue; if it is 005 it is a user.
I am mid development of the following trigger to create a task assigned to the new Owner (only where the owner is not a queue) when the enquiry_details__c <> ''.
I think this will work but it requires testing.
Sorry I'll let you spot the deliberate mistake of typing OOG (letter Oh) not 00G (number zero).
:robotvery-happy:
OK 3rd post in a couple of hours, I did say I was mid development. I think I am finished.
Note: I am not a coder! I beg, borrow and steal code from wherever I can to get a job done. Don't blame me if it's wrong. Any suggestions from real coders would be most appreciated.
I wish you could edit posts :(
the line
should be