Any DB transaction method supported?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-23-2018 03:13 AM
Hi all,
I've looked into GlideRecord API but there isn't any method to handle DB transaction (rollback/commit). I have 2 questions as below:
Question 1:
In server script, I have a while loop to insert 3 records at the same time. The requirement is all 3 records are committed or nothing is committed. In case record 2 is inserted unsuccessfully, I want to rollback record 1. Is there any way to do that?
Question 2:
In case of using Embedded list, when submitting form, all embedded records are submitted along with the parent record. The parent record is inserted first, then each embedded record. If there is error with any embedded record, I want to rollback the entire transaction. Is it possible? How?
Thanks in advance.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-23-2018 04:55 AM
Hi,
GlideRecord doesn't provide you commit/rollback features but you can certainly deal with your scenario through basic javascript function and GlidRecord.
e.g. for the 1st scenario, you can insert a record and if you see 2nd one is not inserted, you can always delete the first one by keeping the first record number in an array.
Thanks
Gaurav

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2021 12:13 PM
This is not the right solution. It does not provide a transaction-level integrity. It is cumbersome if the number of records increases from 3 to a very higher number say 1 million.