Save item transaction
- 7 years ago
Hello,
This kind of transaction rollback exists inherently inside of Aras Innovator. For example, if I run the method code below, the transaction that created the Part will be rolled back because of the error thrown at the end.
Innovator inn = this.getInnovator();
// Create a new partItem part = inn.newItem("Part", "add");part.setProperty("item_number", "My Part 1");part.apply();// The part now exists in the database
// But the transaction is rolled back when this error is thrown// If we check for the part after running this method, it will not existreturn inn.newError("Can not add part");This kind of transaction rolls back for any number of nested server calls. For instance, if I call another method which successfully creates an item and then throw an error, the item created in the called method is still part of the same transaction and will be rolled back when the error is thrown from the calling method. Similarly, if an error is thrown in a server event, any and all transactions associated with the triggering item or any other server events will be rolled back.
I'd suggest taking a look at your existing approach to see if some of this logic could be migrated from the client to the server. We typically recommend keeping this kind of logic inside of a server event so that the same functionality will be run whether the item is saved through the client or an external application.
Chris