Let's say I have a CRUD script that does some actions for OnCreate/OnUpdate/OnDelete.
If that script fails for any of the action, I would like to rollback the changes to the DOMInstance.
In this cases I'm considering the creation of the instance and the execution of the script as a single transaction
Could I work with a DomBehaviorDefinition where each state represents a part of the transaction?
Hi Tim,
What Jens suggested could be an easy approach to get the intended behavior. Do keep in mind that this could introduce an infinite loop.
In general, I would not recommend an approach where a DOM instance is rolled back to a previous version using CRUD scripts. The exact use-case is not exactly clear from the original question, but if you would have some configuration that you define on a DOM instance, which could be 'denied' or result in a failure, I would opt to use a state system as you already mentioned. Some flow where the DOM instance moves to. "Initial" -> "To Accept" -> "Accepted". But if the configuration causes a failure, it will move from "To Accept" to "Failed". A user can then change the DOM instance and move it back to "To Accept" to try again.
Ideally, you would not even use CRUD scripts but do this validation but do it in de scripts that do the status transitions. Let me know if you want to sync on the best approach for your use case.
Hi Tim,
I guess you can use OnDomInstanceCrudWithFullMeta for this where you have the previous DOM Instance before the changes. Or even the current DOM Instance before you do some changes in your CRUD. You can use a try-catch and apply the current or previous version in case of a CRUD script crash.
This could be an easy approach to get the expected behavior. Do keep in mind that this could create a loop if the original version that you will roll back to would also cause the script to fail.
Scheduled in a meeting for Monday, thanks