MongoDB.CommitTransaction
-------------------------

Commit a multi-document transaction.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [MongoDB](component_MongoDB.md) | [12.5](newinversion125.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "MongoDB.CommitTransaction"; MongoDBRef ) 

**MBS**( **"MongoDB.CommitTransaction";** /\* Commit a multi-document transaction. \*/  
**$MongoDBRef**) /\* The reference number for the mongo connection.e.g. $MongoDB \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| MongoDBRef | The reference number for the mongo connection. | $MongoDB |

### Result

Returns JSON or error.

### Description

Commit a multi-document transaction.  
Returns JSON if the transaction was committed. Raises exception if there are invalid arguments, such as a session with no transaction in progress, or if there is a server or network error.  
### Examples

Try insert with commit:

 # Open connection first, open database and connection   
Show Custom Dialog \[ "Estimate before" ; MBS ( "[MongoDB.EstimatedDocumentCount](MongoDBEstimatedDocumentCount.md)"; $mongo ) \]   
\#   
\# insert a record   
Set Variable \[ $r ; Value: MBS ( "[MongoDB.InsertOne](MongoDBInsertOne.md)"; $Mongo ; test::Insert JSON) \]   
Show Custom Dialog \[ "Result" ; $r \]   
\#   
Show Custom Dialog \[ "Estimate after insert" ; MBS ( "[MongoDB.EstimatedDocumentCount](MongoDBEstimatedDocumentCount.md)"; $mongo ) \]   
Set Variable \[ $r ; Value: MBS ( "MongoDB.CommitTransaction"; $Mongo ) \]   
\#   
Show Custom Dialog \[ "Estimate after abort" ; MBS ( "[MongoDB.EstimatedDocumentCount](MongoDBEstimatedDocumentCount.md)"; $mongo ) \]  
### See also

- [MongoDB.AbortTransaction](MongoDBAbortTransaction.md)
- [MongoDB.EstimatedDocumentCount](MongoDBEstimatedDocumentCount.md)
- [MongoDB.InsertOne](MongoDBInsertOne.md)
- [MongoDB.InTransaction](MongoDBInTransaction.md)
- [MongoDB.StartTransaction](MongoDBStartTransaction.md)

### Release notes

- **Version 12.5**
    - Added [MongoDB.StartTransaction](https://www.mbsplugins.eu/MongoDBStartTransaction.shtml), [MongoDB.CommitTransaction](https://www.mbsplugins.eu/MongoDBCommitTransaction.shtml), [MongoDB.InTransaction](https://www.mbsplugins.eu/MongoDBInTransaction.shtml), [MongoDB.AbortTransaction](https://www.mbsplugins.eu/MongoDBAbortTransaction.shtml) and [MongoDB.TransactionState](https://www.mbsplugins.eu/MongoDBTransactionState.shtml) functions.

### Blog Entries

- [MBS FileMaker Plugin 12.5 News](https://www.mbsplugins.de/archive/2022-11-17/MBS_FileMaker_Plugin_125_News/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 12.5pr1](https://www.mbsplugins.de/archive/2022-09-29/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 1/2025, Seite 26](https://filemaker-magazin.de/neuigkeit/4282-Appetithappen-FMM_202501)

This function checks for a license.

Created 23th September 2022 , last changed 24th September 2022

  
[MongoDB.Command](MongoDBCommand.md) - [MongoDB.Connect](MongoDBConnect.md)

[HTML Version](MongoDBCommitTransaction.shtml)