Managing transactions - SmartPlant Foundation - IM Update 44 - Customization & Programming - Hexagon

SmartPlant Foundation Customization

Language
English
Product
SmartPlant Foundation
Search by Category
Customization & Programming
SmartPlant Foundation / SDx Version
10

An implementation to support the Issue example is as follows.

CoreModule.Transaction.Begin()

Try

Dim lobjChangeIObject As IObject = Me.ObjectItem.GetObject()

' Call a method on an interface (methoddef)

CoreModule.Transaction.Commit()

Catch ex As Exception

If CoreModule.Transaction.InTransaction Then CoreModule.Transaction.Rollback()

Throw New SPFException(1391, "There was an error updating the change object.")

End Try

The Try/Catch block will detect an exception and then rollback the transaction. In the case where everything is ok it will just commit the transaction.