Agent to print a view

Hello,

searched here without any statisfactory post.

So, I need an agent that prit out a view - daily. The agent should be scheduled.

I know that @Command won’t work. For view-class there’s no print method - only notesuiview, but you the viewname is set to workspace.Currentview.

Any solution known?

Thank all.

Subject: Maybe…

I have not tested the following code and have no idea if it will work on not.

You would like to create an agent that will print all documents in a database that have a field set to some value,

and then toggle the field after the document has been printed.

Notes can not schedule UI events.

Printing is UI event (Print method in LotusScript and @Command([FilePrint]) for @Commands).

To overcome this limitation you must have a trigger in the UI.

Solution:

There are two ways to do this:

  1. Write your own DLL that you will call pull into notes using the Declare statement and call from the back end.

  2. If you don’t mind keeping a database opened, you can create a new instance of a timer in the Notes database

script when it is opened. You will then have a process which can allow scripts to be run in the UI environment, through

the handler for that trigger.

The following script illustrates this concept.

In this Script assume that the documents have a field called prop which is used for toggling the print property

assume that you have a method to set the property prop to “1” so it will be printed.

put the following script into the database script

(Declarations)

Dim MyTimer As NotesTimer 'This is a Global Variable to store MyTimer

Sub Postopen(Source As Notesuidatabase)

 'The following initializes MyTimer to run every 10 seconds and when this event occurs then

 'Run MyTimerHandler

 Set MyTimer = New NotesTimer(10, "This is my timer for every 10 seconds")

 On Event Alarm From MyTimer Call MyTimerHandler

End Sub

Sub MyTimerHandler(Source As NotesTimer)

%REM

This Sub is called every time an event is generated for MyTimer (every 10 seconds)

%END REM

 Dim w As New notesuiworkspace                    'Holder for the UIWorkspace

 Dim s As New notessession                               'Holder for the Session

 Dim db As notesdatabase                                  'Holder for the Database

 Dim dc As notesdocumentcollection               'Holder for a Document Collection

 

 Dim uid As notesuidocument                           'Holder for the UIDocument

 Dim d As notesdocument                                  'Holder for the Document

 

 Set db = s.currentdatabase                             'Get a handle to the database

 Set dc = db.alldocuments                                'Get a handle on all of the documents

 

 For i = 1 To dc.count                                          'Loop through all of the documents

      Set d = dc.getnthdocument(i)                     'Get the ith document

      If d.prop(0) = "1" Then                                  'If The prop field has been set to print

           d.prop = "0"                                                 'Toggle the property

           Call d.save(False,False)                        'Save the document

           Set uid = w.EditDocument(False,d,True) 'Get a handle to the front end of the document

           Call uid.print(1)                                           'Print the document

           Call uid.close                                             'Close the document

      End If

 Next

End Sub

Supporting Information:

NOTE: The timer may not be every 10 seconds as specified because of other events scheduled on the server.

NOTE: This may cause a decline in performance in this is run on a server.