Force Transaction to Write to the Database

I have a Function that runs on a regular schedule and gets a JSON list of items. I look through each item and create (using the BOs) a bunch of Orders. This works well if there is not data issues. However, when there is a data issue, the whole process fails and no Orders are created (although the order number is incremented).
I see a couple options:

  1. Log the status of each item in a log file and use try/catch to allow the process to continue
  2. Same as above, but write this to the SysTaskLog table (ideal, but no clue how to get the current task accurately)
  3. Force the good records to write and only fail on the errors.

This post is about #3. How can I force the transaction to write at the end of the code inside a loop?

You’ll have to either call the function for each record or inside the function loop call another function for each record that has its own transaction scope

That follows. Thanks!

Jason Woods
http://LinkedIn.com/in/jasoncwoods