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:
- Log the status of each item in a log file and use try/catch to allow the process to continue
- Same as above, but write this to the SysTaskLog table (ideal, but no clue how to get the current task accurately)
- 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?