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

Can we limit users from taking any leads from queue when they have uncontacted leads?
Hi All,
I want to have leads be able to take x number of leads from the queue at a time and the next time they want to take they should not be having any uncontacted leads which are coming from the queue.
Please help
I want to have leads be able to take x number of leads from the queue at a time and the next time they want to take they should not be having any uncontacted leads which are coming from the queue.
Please help
You may try to Set Up Assignment Rules for leads.
Refer below salesforce help article
https://help.salesforce.com/articleView?id=creating_assignment_rules.htm&type=5
Best Regards,
Sandhya
I want to limit the user from accepting any leads when a user has any open leads
Not sure if I can use assignment rule here.
Thanks for responding,
Domnic
<pre>
trigger LimitLeads on Lead ( before update )
{
Integer maxLeads = 4;
Map<Id,List<Lead>> leadsByNewOwnerId = new Map<Id,List<Lead>>();
for ( Lead lead : Trigger.new )
{
Lead oldLead = Trigger.oldMap.get( lead.Id );
if ( oldLead.OwnerId != lead.OwnerId
&& String.valueOf( lead.OwnerId ).left( 3 ) == '005'
)
{
if ( !leadsByNewOwnerId.containsKey( lead.OwnerId ) )
{
leadsByNewOwnerId.put( lead.OwnerId, new List<Lead>() );
}
leadsByNewOwnerId.get( lead.OwnerId ).add( lead );
}
}
for ( AggregateResult result :
[ SELECT COUNT(Id), OwnerId
FROM Lead
WHERE ( Status = 'Open - Not Contacted'
AND OwnerId IN :leadsByNewOwnerId.keySet()
)
GROUP BY OwnerId
HAVING COUNT(Id) >= :maxLeads
]
)
{
for ( Lead lead : leadsByNewOwnerId.get( (Id) result.get( 'OwnerId' ) ) )
{
lead.addError
( 'Users cannot have more than '
+ maxLeads
+ ' "Open - Not Contacted" leads.'
);
}
}
}
</pre>
Thanks for the code. So, whats happening is if the user has more than 4 or more uncontacted leads the user is not able to accept any leads from the queue. But if the user has less than 3 uncontacted leads, the user is able to accept any number of leads from the queue.
Is there a way to limit the number of leads the user can accept from the queue?
Thanks again,
Domnic