You need to sign in to do that
Don't have an account?

Writing an Apex Trigger
Hi,
Can you write an apex trigger to assign all incoming leads in a Round-Robin fashion to users based on the following criteria
1.If the lead RecordType = ‘US Lead’, then assign the lead to users with country = ‘USA’
2.If the lead RecordType = ‘International’, then assign the lead to users with Country != ‘USA’
For eg., if there are only 3 users(User1,User2,User3) with country = ‘USA’ in the system then the first lead with RecordType = ‘US Lead’ will be assigned to User1, Second lead with RecordType = ‘US Lead’ will be assigned to User2 and so on.
The same logic applies to international leads.
Thanks in Advance..
Can you write an apex trigger to assign all incoming leads in a Round-Robin fashion to users based on the following criteria
1.If the lead RecordType = ‘US Lead’, then assign the lead to users with country = ‘USA’
2.If the lead RecordType = ‘International’, then assign the lead to users with Country != ‘USA’
For eg., if there are only 3 users(User1,User2,User3) with country = ‘USA’ in the system then the first lead with RecordType = ‘US Lead’ will be assigned to User1, Second lead with RecordType = ‘US Lead’ will be assigned to User2 and so on.
The same logic applies to international leads.
Thanks in Advance..
I cannot help you in writting a code. As this is not the right place for these kind of queries.
Though, you can try creating one using following link:
https://help.salesforce.com/articleView?id=000004000&type=1
Hope this will give you an idea of achieving your task.
Please mark this as solution by selecting it as best answer if this solves your problem, So that if anyone has this issue this post can help.
It's a bit more complicated than just a trigger. You need to decide if it's a round robin for ALL users or not. If it's not all user's then you have to modify the User object somehow to keep track of who is eligible for consideration, and who the next (or last) user is.
I will recommend you to use Lead Assignment rule for same. You can do same without Trigger
My requirement is to write a Trigger ..So please help me on this
You have to understand the flow here. The functionality you are trying to achieve is not possible through trigger.
You have to use combination of assignment rules, queues and some cutom logic which would perform round robin.