I have a function to change a field name using DocMetaData.Field which always works, except for this new situation, which occurs after a CreateCopyOf. The error occurs in the second function. Here is the code, which I hope is clear -
oLaserfiche.CopyDocumentWithTemplate(4, lfDoc, sLfRepository, lfDoc.FullPath, lfDoc.Name, "_Copy1")
iNewTocId = lfDoc.ID
oLaserfiche.UpdateLaserficheDocumentFieldValue("Type", sType, lfDoc)
'Called function #1 -
Public Sub CopyDocumentWithTemplate(ByVal ApplicationId As String,
ByRef lfDoc As LFDocument,
ByVal sLfRepository As String,
ByVal FolderPath As String,
ByVal FileName As String,
ByVal NewFileNameSuffix As String)
Dim Application As String = String.Empty
Dim ReturnedMessage As String = String.Empty
Dim ActiveRepository As LFDatabase = Nothing
Dim CurrentDoc As LFDocument = Nothing
Dim ParentFolder As LFFolder = Nothing
Dim CopyDoc As New LFDocument
Dim iApplicationId As Integer = 0
Dim iTocID As Integer = 0
If FolderPath <> "" Then
Try
ActiveRepository = InitializeLaserficheConnection()
CurrentDoc = New LFDocument
CurrentDoc = ActiveRepository.GetEntryByPath(FolderPath)
ParentFolder = ActiveRepository.GetEntryByPath(sLfRepository & FolderPath.Replace("\" & FileName, ""))
CopyDoc.CreateCopyOf(CurrentDoc, FileName & NewFileNameSuffix, ParentFolder, True)
CopyDoc.Update()
lfDoc = CopyDoc
Catch ex As Exception
ReturnedMessage = "CopyDocumentWithTemplate. Error - " & ex.Source & "<br/> " & ex.Message
Finally
If Not CurrentDoc Is Nothing Then
CurrentDoc.Dispose()
End If
If Not CopyDoc Is Nothing Then
CopyDoc.Dispose()
End If
If Not ActiveRepository Is Nothing Then
DisconnectLaserficheConnection(ActiveRepository)
ActiveRepository = Nothing
End If
End Try
End If
End Sub
'Called function #2 -
Public Function UpdateLaserficheDocumentFieldValue(ByVal sFieldName As String, _
ByVal sFieldValue As String, _
ByRef lfDoc As LFDocument) As Boolean
Dim DocMetaData As LFFieldData = Nothing
Dim bReturn As Boolean = True
Try
DocMetaData = lfDoc.FieldData()
If Not DocMetaData.IsLocked Then
'NEXT LINE HAS ERROR!
DocMetaData.LockObject(Lock_Type.LOCK_TYPE_WRITE)
End If
'NEXT LINE HAS ERROR if I skip LockObject
DocMetaData.Field(sFieldName) = sFieldValue
DocMetaData.Update()
Catch ex As Exception
ex.Source &= m_csModName & ".UpdateLaserficheDocumentFieldValue" & vbNewLine
Throw
bReturn = False
Finally
If DocMetaData.IsLocked Then
DocMetaData.UnlockObject()
End If
End Try
Return bReturn
End Function
I greatly appreciate any help.
Howard