mikaelsnavy of CaseTrakker Dynamo Snips
11/18/2015 - 4:59 PM

Lock CaseTrakker record or defer record if record is currently lock

Lock CaseTrakker record or defer record if record is currently lock

Dim record As CaseTrakker.Framework.Script.RecordScriptExtension = Globals.CurrentRecord
Dim recordId As String = record.Value("ct_id").Value

' Load the record (not usually needed if executed on current record)
'record = Globals.CurrentSession.LoadRecord(1, recordId)
Try
	' Lock the record
	Dim recordLock As CaseTrakker.Framework.Script.RecordLockScriptExtension = Globals.CurrentSession.LockRecord(110, recordId, False)
	Try
		' Do stuff with the record
	Finally
		' Make sure we release the lock if we got it
		recordLock.ReleaseLock()
	End Try
Catch ex As CaseTrakker.Framework.RecordLockFailedException
	' Record was locked, so defer
	Globals.CurrentWorkflow.DeferActionPendingLock(recordId)
End Try