AnsweredAssumed Answered

How to perform atomic transaction through the SugarCRM REST API (commit/rollback)

Question asked by William William on Jul 20, 2015
Latest reply on Oct 24, 2017 by Cédric Mourizard

I'm working on a PHP module that exports data to a SugarCRM Enterprise (version by its v10 REST API.

I have some cases such as the following, i export a contact and multiple contact's addresses related to the first one by a relationship. However, i would like to handle an atomic transaction while i export a contact's address.

Let's suppose a contact named John Doe exists.
  • On a first step, i'm exporting one of his address through the REST API.
  • On a second step, i have to link this address to the contact, still through the API. But, if the linking process fails, i don't want the contact's address to be created.
Therefore, i made some researches and i can't find a way to perform something like commit/rollback in SQL transaction. The idea is to make a sandbox for the transaction: if the linking is done, then it commits the transaction, otherwise, it rollbacks it.

Thank you in advance for your helps.


Edit: I was thinking of linking the two objects and if it fails, it deletes the contact's address. But, is there a simpler way to handle that ?