+ Start a Discussion
Mike SummittMike Summitt 

Too many updates on Zuora 360 sync.

I had a pair of triggers that fired from Zuora 360 doing inserts or updates to its productrateplan or subscription objects. Zuora's replication strategy often deletes and re-adds these records, causing their SFID to change.  As a result, the triggers had a lot of work to do finding other references to the object and correcting them.  It couldn't be done with workflow because there are no master/detail relationships.

Both triggers started occasionally generating SOQL limit errors (the dreaded 101) even though they were fully bulkified.  To stop this, I moved a segment of bulkified logic into an Apex method marked with @future, so that the "key fixup" would be in a different scope and wouldn't hit the limit.

Unfortunately, the update to productrateplan sometimes causes changes to subscription records, which then cause the subscription trigger to fire.  Even though the @future method didn't directly call another @future method, but only did an update which fired a trigger which called a @future method, SF still detected it and blocked the attempt.  Also, I'm now getting other error messages, including "First exception on row 0 with id a1si0000002Gf3xAAC; first error: UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record: []".

Does anyone have suggestions on how else this could be implemented?  The changes are all "fixups", the specified SFID has been nulled by Zuora's delete operation, now the records must be found using alternate keys and the restoring the new SFID.