cancel
Showing results for 
Search instead for 
Did you mean: 

Rollback transaction in Javascript back-end Web Script

guillaumefranco
Champ in-the-making
Champ in-the-making
Hello,

I would like to rollback transaction inside a JavaScript back-end WebScript

Currently, I can't manage to do this. Transaction are only roll-backed when a error occurs during execution of JavaScript (like reading value from a null object) or when a Freemarker rendering occurs.

If I put
status.code = 500;
status.message = "I wan't to rollback";
status.redirect =true;
Error message is displayed but transaction is not rollback.

I would like to have such a thing in order to specialize code and error message and have ability to perform rollback on demand.

Should I use the transactionService ??? Wiki only says this
Extreme care must be taken when using certain Alfresco APIs, for example the transaction APIs. This is because in many cases the Alfresco scripting framework includes logic that handles some of these "plumbing" concerns automatically - for example the Javascript script for a Web Script is automatically executed within an Alfresco transaction - programmatic transaction handling within the Javascript is not required and may interfere with the default behaviour.
1 REPLY 1

openpj
Elite Collaborator
Elite Collaborator
You should implement a Java-Backed WebScripts configuring the descriptor with <transaction>none</transaction> and using inside in the Java implementation the RetryingTransactionHelper as you can see in the FirstFoundationClient that you find as an example in the Alfresco SDK. In this way you can decide when the rollback must be triggered.

Hope this helps.