Jump to content

Transactional scripting & dependency on newly created records


This topic is 1752 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies

Hi, I started this project using transaction to interact with the data, I used the transaction module from KarbonFM to do so. I have a situation where one of the script called during the transaction fails because it want to validate that a record exists before doing what it has to do. Because the said record is created as part of the same transaction, the script does not 'see' the newly created record via the relationship because it is not committed yet. Is there any way around that?

 

Thanks for your help

Link to comment
Share on other sites

For the sake of readers here, I'll also post my response here:

Quote

Two options.

Commit before you go to the other script.
Solid error checking negates the need to validate that the record is there. If the record is in the process of being created, and does not fail, you can assume the record is there. If you are using that script from other scripts where it is expected the record is already there, you can either move the validation to before you call the transaction ( make sure everything is in place first before you execute the script ) or fork the script to account for the two different flows. Depends a lot on how you are developing.

 

Semi-quote with some updates because of context:

Quote

Getting the most out of transactions comes down to pulling out the reusable pieces, and separating them into their own script. The process of editing a record is really the same most of the time. The only differences will usually be the actual data, and which fields are being set. So handle the business logic before you send it to the script that actually sets the data or creates the records.

 

Link to comment
Share on other sites

  • Newbies

@Josh Ormond Thank you, I know we exchanged on this topic elsewhere, but taking the time to recap essential elements here as well for the benefit of as many people as possible is outstanding dedication. "Mille fois merci!"

  • Like 1
Link to comment
Share on other sites

This topic is 1752 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.