Jump to content
Sign in to follow this  
Robert Naud

Transactional scripting & dependency on newly created records

Recommended Posts

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

Share this post


Link to post
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.

 

Share this post


Link to post
Share on other sites

@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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

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