You are viewing limited content. For full access, please sign in.

Question

Question

set extension via SDK

asked on April 5, 2019 Show version history

I'm looking to set the Extension for electronic documents after uploading them via the SDK. I already have an LFDocument handle of the object just uploaded. While this code compiles and runs, it is not actually changing the extension in LF. 

docInfo.LockObject(Lock_Type.LOCK_TYPE_WRITE); 
docInfo.ElectFile.Extension = extension;
docInfo.Update(); // Clears document handles. 
docInfo.Dispose();

Thoughts on why this would not be updating the LFDocument's extension?

0 0

Answer

SELECTED ANSWER
replied on April 8, 2019 Show version history

You need to lock and work with the ElectFile object.  Below is your function in VB updated to work

    Private Function AlterFileTypeExtension(ByVal docInfo As LFDocument, ByVal sExt As String) As Boolean
        Try
            Dim elecDoc As LFElectFile = docInfo.ElectFile
            elecDoc.LockObject(Lock_Type.LOCK_TYPE_WRITE)
            elecDoc.Extension = sExt
            elecDoc.Update()
            elecDoc.UnlockObject()
            Return True
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            Return False
        End Try
    End Function

And I called it like

                Dim doc As LFDocument = LFDB.GetEntryByID(iDocId)
                AlterFileTypeExtension(doc, sExtension)
                doc.Dispose()

 

1 0

Replies

replied on April 5, 2019

Try calling docInfo.ElectFile.Update() after setting the extension on docInfo.ElectFile.

0 0
replied on April 8, 2019

We're not getting to that step yet; literally, the SET command is not setting the property. Even if I manually attempt to assert the value in the debugger, it is immediately reverted. I wonder if this is read-only, even though it has a SET function in the definition.

extension-not-allowing-set.PNG
0 0
SELECTED ANSWER
replied on April 8, 2019 Show version history

You need to lock and work with the ElectFile object.  Below is your function in VB updated to work

    Private Function AlterFileTypeExtension(ByVal docInfo As LFDocument, ByVal sExt As String) As Boolean
        Try
            Dim elecDoc As LFElectFile = docInfo.ElectFile
            elecDoc.LockObject(Lock_Type.LOCK_TYPE_WRITE)
            elecDoc.Extension = sExt
            elecDoc.Update()
            elecDoc.UnlockObject()
            Return True
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            Return False
        End Try
    End Function

And I called it like

                Dim doc As LFDocument = LFDB.GetEntryByID(iDocId)
                AlterFileTypeExtension(doc, sExtension)
                doc.Dispose()

 

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.