7.3 beta: Duplicate Check handler does not complete transaction
We have a service that syncs some records from an external system.
Through an API call we fetch the records and then loop through them and create records in Vtiger. Also we have put the save call under a try catch block.
Now if a duplicate exception is thrown it goes to the catch block and so the transaction which started on call to save function never ends. As such when the cron execution finishes everything rolls back. Also, leading to the scheduled job never changing to completed status, it always remains in Running state.
To fix this we have to add $adb->completeTransaction in the catch block.
The better way to handle this is to call completeTransaction when the duplicate exception is being thrown.
Moreoever, if we have an email workflow setup, it triggers the email, but in the CRM you would see no respective record, as a rollback has occired. Haven't been able to find the cause for this yet. The worklfows are triggered aftersave, so logically it should not trigger the email workflow. Yet to debug.