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

Question

Question

Delete existing textbox annotations on documents

asked on April 3, 2015

I want to have a business process that can be run on a starting document to find existing textbox annotations and delete them. I can create a script to add a textbox annotation, but I seem to be missing the annotation type ID for the delete script.

  • How do I get the annotation type ID?

I would also be interested in seeing any suggested code for this script.

0 0

Answer

SELECTED ANSWER
replied on April 3, 2015 Show version history

The same principle applies. You can't call GetAnnotation without the ID, so you can find the ID by iterating through all the annotations of a specific type.

1) Get all annotations ( GetAllAnnotations(Annotation_Type.ANN_STAMP) )

2) Iterate through the annotations list and extract the annotation ID. Each annotation in the listing has multiple columns, one of this is the ID.

3) For each ID that you care about (in your case, it sounds like all of them) get that annotation using GetAnnotation, then delete it.

 

1 0

Replies

replied on April 3, 2015

Please see this previous answers post, which has a script snippet for deleting pre-existing stamp annotations https://answers.laserfiche.com/questions/47353/Deleting-arbitrary-annotations-with-SDK

2 0
replied on April 3, 2015

Thanks, Kevin. I did read that post, but since all my existing scripts are written in visual basic, I'm not able to easily modify it. I'm trying to get a quick fix for an exception to the rule. My documents only have a textbox annotation that was added in a previous workflow. I need to pull the ID as the delete method uses that, not annotation type. If I knew the ID I could simply write that into my code and be done with it.

So...here is my script - it doesn't work - it get's this error message - Error 1 Argument not specified for parameter 'itemId' of 'Public Function GetAnnotation(itemId As Integer) As Laserfiche.RepositoryAccess.AnnotationBase'. \SDKScript\Script 1.vb 29  RemoveTextBox
 

Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Data.SqlClient
Imports System.Text
Imports Laserfiche.RepositoryAccess

Namespace WorkflowActivity.Scripting.SDKScript
    '''<summary>
    '''Provides one or more methods that can be run when the workflow scripting activity is performed.
    '''</summary>
    Public Class Script1
        Inherits RAScriptClass91
        '''<summary>
        '''This method is run when the activity is performed.
        '''</summary>
        Protected Overrides Sub Execute()

If Me.BoundEntryInfo.EntryType = EntryType.Document Then


             'Get a reference to page 1 of the bound entry...

                Dim pInfo As PageInfo = Document.GetDocumentInfo(Me.BoundEntryId, Me.RASession).GetPageInfo(1)


               'Find itemID
                 Dim tAnnotation As Integer = pinfo.GetAnnotation()
        
                 pInfo.DeleteAnnotation(tAnnotation)
            End If
        End Sub

    End Class

End Namespace

Thank you, I do appreciate your assistance.

replied on April 3, 2015

Thanks, Kevin. I did read that post, but since all my existing scripts are written in visual basic, I'm not able to easily modify it. I'm trying to get a quick fix for an exception to the rule. My documents only have a textbox annotation that was added in a previous workflow. I need to pull the ID as the delete method uses that, not annotation type. If I knew the ID I could simply write that into my code and be done with it.

So...here is my script - it doesn't work - it get's this error message - Error 1 Argument not specified for parameter 'itemId' of 'Public Function GetAnnotation(itemId As Integer) As Laserfiche.RepositoryAccess.AnnotationBase'. \SDKScript\Script 1.vb 29  RemoveTextBox

Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Data.SqlClient
Imports System.Text
Imports Laserfiche.RepositoryAccess

Namespace WorkflowActivity.Scripting.SDKScript
    '''<summary>
    '''Provides one or more methods that can be run when the workflow scripting activity is performed.
    '''</summary>
    Public Class Script1
        Inherits RAScriptClass91
        '''<summary>
        '''This method is run when the activity is performed.
        '''</summary>
        Protected Overrides Sub Execute()

If Me.BoundEntryInfo.EntryType = EntryType.Document Then


             'Get a reference to page 1 of the bound entry...

                Dim pInfo As PageInfo = Document.GetDocumentInfo(Me.BoundEntryId, Me.RASession).GetPageInfo(1)


               'Find itemID
                 Dim tAnnotation As Integer = pinfo.GetAnnotation()

                 pInfo.DeleteAnnotation(tAnnotation)
            End If
        End Sub

    End Class

End Namespace


Thank you, I appreciate your assistance.

0 0
SELECTED ANSWER
replied on April 3, 2015 Show version history

The same principle applies. You can't call GetAnnotation without the ID, so you can find the ID by iterating through all the annotations of a specific type.

1) Get all annotations ( GetAllAnnotations(Annotation_Type.ANN_STAMP) )

2) Iterate through the annotations list and extract the annotation ID. Each annotation in the listing has multiple columns, one of this is the ID.

3) For each ID that you care about (in your case, it sounds like all of them) get that annotation using GetAnnotation, then delete it.

 

1 0
replied on April 7, 2015

Thanks, Brianna. I get it now. I thought there was a static ID for all textbox annotations and the iteration was to find the specific static ID.

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

Sign in to reply to this post.