1

I'm a young Apex developer. I have a quick question:

I would like to dynamically assign new records to users using an Apex trigger. As we know, every new created records are automatically assigned to the current logged in user.

I am trying to create a trigger that assigns the leads between the 2 users equally. The solution should count the number of leads assigned to each user, so that we have similar number of leads assigned to each user.

For example: - You have User C and User D - You mass insert 7 lead records - Leads 1, 3, 5 and 7 are assigned to User C - Leads 2, 4 and 6 are assigned to User B

  • As an alternative, have you thought about using a Lead Queue and letting the Reps pull from there? – Daniel Ballinger Mar 26 '14 at 21:34
  • You could also use Lead Assignment Rules. Possibly in conjunction with lead queues. – Daniel Ballinger Mar 26 '14 at 21:34
4

What you're looking for is called "round robin" assignment.

1) If you want to custom build it, you can find the approach on a similar question that I've answered for Cases and Accounts here. You would need to do the same thing for the users and leads.

2) There is an app called "Round Robin Record Assignment" on the appexchange, I personally haven't tried it, but looks like it does what you need and it's free.

3) You can also achieve this by creating a couple of custom fields and assignment rules. A very good example can be found here

  • Thank you so much for your reply. I will look to this and back with the answer. Thank you ! – teluch91 Mar 26 '14 at 22:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.