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

Question

Question

Deleting DocumentInfo using SDK 9

asked on January 24, 2014

How can I delete a document using sdk 9?

 

DocumentInfo document = Document.GetDocumentInfo(5, session);
document.Delete();

 

This method don't work

 

 

0 0

Answer

SELECTED ANSWER
replied on January 24, 2014 Show version history

Thom,

 

To delete a document using RA you would actually get a reference to the EntryInfo object not the DocumentInfo object.  Here is a code snippet to delete an entry using RA;

 

        Dim myRegistration As New RepositoryRegistration("localhost", "LFMAIN")
        Dim mySession As New Session
        Dim myEntry As EntryInfo

        mySession.LogIn("admin", "admin", myRegistration)

        myEntry = Entry.GetEntryInfo(94554, mySession)

        myEntry.Lock(LockType.Exclusive)
        myEntry.Delete()
        myEntry.Save()
        myEntry.Unlock()

        myEntry.Dispose()

        mySession.Close()
        mySession = Nothing
        myRegistration = Nothing

 

1 0
replied on January 24, 2014

DocumentInfo.Delete works as well. In fact, DocumentInfo inherits from EntryInfo so it's really the same method. It didn't work because you didn't call DocumentInfo.Save. However, if you just want to delete a document by its ID and you don't want to query any properties on the document, then the most efficient way is to call the static method Entry.Delete. There is no need to lock a document if you are going to immediately delete it.

1 0
replied on January 24, 2014

Michael - Makes sense.  I went to the reference guide to respond to Thom's question.  The 9.0 SDK documentation does not list a DocumentInfo.Delete method so I used the reference to the EntryInfo object instead.

0 0
replied on January 25, 2014 Show version history

So for completeness here is an RA code snippet that will delete a document without instantiating the DocumentInfo object;

 

        Try
            Dim myRegistration As New RepositoryRegistration("localhost", "LFMAIN")
            Dim mySession As New Session

            mySession.LogIn("admin", "admin", myRegistration)

            Entry.Delete(94689, mySession)

            mySession.Close()
            mySession = Nothing
            myRegistration = Nothing

        Catch ex As Exception

            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK)

        End Try

 

Replies

replied on January 25, 2014 Show version history

So for completeness here is an RA code snippet that will delete a document without instantiating the DocumentInfo object;

 

        Try
            Dim myRegistration As New RepositoryRegistration("localhost", "LFMAIN")
            Dim mySession As New Session

            mySession.LogIn("admin", "admin", myRegistration)

            'Call the static Entry method to delete a document...  
            'Parameters are the entryID and the session object...
            Entry.Delete(94689, mySession)

            'Cleanup...
            mySession.Close()
            mySession = Nothing
            myRegistration = Nothing

        Catch ex As Exception
            'Display any errors...
            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK)

        End Try
 

 

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

Sign in to reply to this post.