Hi! Every night we run a batch campaigns that update our lead scoring model. One of these campaigns captures a particularly large group of leads every night ( ~3k-5k). When this happens Marketo triggers a sync with Salesforce for all those leads. Because Marketo tries to update so many leads in so short a time we hit APEX SOQL limits on a few of our custom triggers (even though they are set up to handle batch requests).
Wondering how others have dealt with this? One idea I had was somehow running the batch campaign that updates lead scoring over the course of a few hours taking a smaller group of eligible leads during each run, but not sure how I would do that. Another idea was to have those leads fail out and then somehow triggering another process that resyncs them, but this isn't ideal.
3-5k isn't that much.
I assume your Lead Score field is synced to SFDC. But your real issue is the Apex trigger, so you should discuss this with your SFDC Admin to optimize the code or adjust the code to better handle the situation. For example, do those triggers "need" to be activated on lead score?
You won't be able to do a controlled batch unless you use Talend.
The apex fail doesn't necessarily mean the lead data didn't sync, so a re-sync isn't likely necessary. Marketo will auto re-attempt a fix later on anyway.
This is a Salesforce issue. Its triggers need to be bulkified and be able to prevent unintended recursion. If you are using process builder, make sure that:
If Process Builder Queries do not appear to be bulkified as expected in your org, contact Support to verify the permission "Enable query optimization in bulk mode" is enabled for your org.
Happy to have someone here take a look at your trigger code and provide feedback on it.
Thanks Ben, we do have that enabled (as of newest release you can enable on your own in critical updates). I will look into the Salesforce trigger code and see if we can add some filters on there.