05-25-2016 05:08 PM
There are many discussions on API_BEGIN/END usage, but I'm still confused...
I was under impression that the following code would rollback the possible changes if success==false:
...some entities changed here...
if ( !success )
result = outcome(API_FAILED);
I was wrong of course: rollback happens only in outermost API_BEGIN/END block if the bad result is propagated.
Hence the question: how can I make sure that possible unwanted changes will be rollbacked? I can't use API_NOP_BEGIN/END since I need to rollback only in some cases, when something went wrong.
Even if the code above works as intended (rollbacks after failure), up-level changes can break it if API_BEGIN/END block will be added into a calling method.
Will option bb_immediate_close help in this case?
Solved! Go to Solution.
05-25-2016 05:15 PM
API_TRIAL_BEGIN/API_TRIAL_END works the way you want (rolls on failure even when nested). That is not the default behavior of API_BEGIN/API_END because it is a performance optimization not to need extra bulletin boards.