MongoDB.StartTransaction
------------------------

Start a multi-document transaction for all following operations in this session.

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

MBS( "MongoDB.StartTransaction"; MongoDBRef ) 

**MBS**( **"MongoDB.StartTransaction";** /\* Start a multi-document transaction for all following operations in this session. \*/  
**$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 OK or error.

### Description

Start a multi-document transaction for all following operations in this session.  
The transaction must be completed with CommitTransaction or AbortTransaction. An in-progress transaction is automatically aborted by destructor.  
Raises exception if there are invalid arguments, such as a session with a transaction already in progress.  
  
If you run MongoDB server locally, you may need to configure a replication. Otherwise you get an error like this: "Error 17:20: Transaction numbers are only allowed on a replica set member or mongos".  
### See also

- [MongoDB.AbortTransaction](MongoDBAbortTransaction.md)
- [MongoDB.CommitTransaction](MongoDBCommitTransaction.md)
- [MongoDB.InTransaction](MongoDBInTransaction.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.

### Example Databases

- [MongoDB/MongoDB Test](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/MongoDB/MongoDB%20Test.shtml#12ScriptAnchor_)

### 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.SetUserName](MongoDBSetUserName.md) - [MongoDB.TextToBinary](MongoDBTextToBinary.md)

[HTML Version](MongoDBStartTransaction.shtml)