I've got an Apex trigger that automatically converts incoming leads if certain conditions are met. These leads are themselves added to the system via an API call from my main application. I've also got a set of lead assignment rules for assigning leads to members of my sales team.
Ideally, then, a customer would fill out an application on my site, be added to Salesforce as a lead, be assigned to one of my sales team, and then be converted to an opportunity. The opportunity would then be owned by the appropriate sales team member.
The problem is that I am often seeing the converted opportunities not being assigned to the same sales person as the lead. It looks like the assignment rules are not run at all: the opportunity is owned by the default assignee of the lead. But I look at the converted lead and it is assigned to one of my sales people - so the conversion to opportunity does not carry over the assignment.
I suspect there is a race condition going on between the lead assignment rule and the automatic conversion of the leads.
Can anyone suggest a solution?
Thanks, Joe