• Jake Allen
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 4
    Replies
I'm not sure exactly where to put this, but to make a long story short, we have several apex triggers and process automations in place that will automatically convert new leads to contacts when the leads are uploaded from a csv. We're running into a number of issues that happen for a portion of the leads being uploaded. The number of leads affected seems to be relative to the number of leads being uploaded. Specific Isuses:
  • Apex trigger that populates a custom contact field may or may not update the contact field. No exception is generated.
  • Apex trigger that maps contact account structure into an organizational structure within our internal software will often create duplicate organizations rather than adding to existing. No exception is generated.
  • Process Flow that adds contact to email campaigns may or may not succeed. When it fails, it give an exception of "UNABLE_TO_LOCK_ROW: unable to obtain exclusive access to this record or 1 records"
I believe what's ultimately happening here is the entire process is stepping on itself, as indicated by the UNABLE_TO_LOCK_ROW error. The entire conversion process is a bit complex and involved, and I'm not sure what details may be helpful here (feel free to ask for specifics), but to outline the process:
  • A user goes to Leads and clicks "Import", then uploads a csv with the required fields for each lead.
  • If a lead is missing a timezone, a process builder grabs it from their associated account and populates the lead (this is required for a later step)
  • An Apex trigger hands off the new leads in batches of 10 to be converted by a separate class.
  • An Apex trigger calls our internal api to create an internal user account, then populates their Salesforce record with their new username
  • A Process Builder adds the contact with the new username into a Salesforce email campaign
What I'd ultimately like here is to get our system working more reliably. Currently we have to put in a good deal of manual intervention whenever a list of leads is uploaded, and I'd like to make this as hands-off as possible. Please let me know if you any suggestions on how to improve the reliability of our workflow or if you need any additional information.
We currently have apex code to convert any new lead to a contact under qualifying conditions after insert and after update, but whenever you either do a bulk import, or if you select multiple leads and change a field (ie, the owner), the trigger will only fire for the first lead in the selection and the rest will never be triggered. Process Builders and other automation will fire correctly, so it's limited to apex triggers exclusively at this point. I presume this is because the trigger looks at it as a single update or transaction, rather than seeing it as multiple leads being updated? Personally I see this as a potential flaw in Salesforce design, but I wanted to know if anybody else has come across this? Is there a setting I'm missing, or maybe a workaround I haven't thought of? I'm at the verge of creating a cronjob to automatically convert qualifying leads, which is something I'd rather avoid if at all possible.
We currently have apex code to convert any new lead to a contact under qualifying conditions after insert and after update, but whenever you either do a bulk import, or if you select multiple leads and change a field (ie, the owner), the trigger will only fire for the first lead in the selection and the rest will never be triggered. Process Builders and other automation will fire correctly, so it's limited to apex triggers exclusively at this point. I presume this is because the trigger looks at it as a single update or transaction, rather than seeing it as multiple leads being updated? Personally I see this as a potential flaw in Salesforce design, but I wanted to know if anybody else has come across this? Is there a setting I'm missing, or maybe a workaround I haven't thought of? I'm at the verge of creating a cronjob to automatically convert qualifying leads, which is something I'd rather avoid if at all possible.