Darn Reoports

This is how I solved most of the reporting in my notes applications. The output of this routine is a document ready for printing, which is by itself a collection of documents. This is the internal working of the process... you will need 2 forms for this routine to work 1. A page layout (Title/ Subtitle/ Date/ Header/ Footer/ Body[rtfield]) 2. A document Template (e.g. status/ assigned to etc...) The idea is the following many 'document...

templates' will be rendered on the print layout, which eventually will be printed. The specific code presented here, builds the collection as well based on some user selections (the click is triggered from a dialog box). The original form is called 'Main', the page layout is called 'PrintPreview', the form for rendering each document for printing is called 'PrintItem'. The real code discussed here is toward the end (last 15 lines or so). Enjoy, Riccardo. Sub Click(Source As Button) 'Written by Riccardo Coen 'distributable freely, just keep these lines comments in. Dim previewUidoc As notesuidocument Dim uidoc As notesuidocument Dim ws As New notesuiworkspace Dim session As New NotesSession Dim db As NotesDatabase Dim view As NotesView Dim docSource As NotesDocument Dim docPrintPreview As NotesDocument Dim rtitem As NotesRichTextItem Dim lookupView As notesview Dim lookupCollection As notesdocumentcollection Dim subject As String Dim success As Variant Dim coll As notesdocumentcollection Dim i As Double Dim formula As String Dim parties As String Dim status As String Dim subtitle As String Dim item As NotesItem Dim cutOffDate As NotesDateTime Dim authorsItem As notesitem '...set value of doc... Set uidoc = ws.currentdocument Set db = session.CurrentDatabase '====================================================== ' STEP ONE 'build the list of document that we will need to print '====================================================== formula = "Form = 'Main' " parties = uidoc.fieldgettext("Parties") status = uidoc.fieldgettext("Status") tmp = "" If parties <> "Any" Then formula = formula & " & (! (@isnotmember( @explode('" & parties & "'); Leader:Follower ))) " End If If status <> "All" Then If status = "Outstanding" Or status = "Assigned" Then tmp = "Outstanding; Assigned" formula = formula & " & (! (@isnotmember( @explode('" & tmp & "'); Status )))" Elseif status = "Overdue" Then formula = formula & "& duedays < 0 " Else formula = formula & "& Status = '"& status &"'" End If End If Set cutOffDate = New NotesDateTime( uidoc.fieldgettext("Created") ) Set coll = db.search(formula, cutOffDate, 0) '===================================================== ' STEP 2 '===================================================== If coll.count>0 Then 'Create the document on which we will be adding output "the print preview" Set docPrintPreview = New NotesDocument( db ) Set rtitem = New NotesRichTextItem( docPrintPreview, "Body" ) docPrintPreview.Form = "PrintPreview" 'lookup subject either on the view or... through a search docPrintPreview.subject = APPLONGNAME '-> defined in script library 'and set the subtitle if required subTitle = Status + " Action Points" + Chr$(10) tmp = "" If Parties <> "Any" Then 'get rid of the ; in the leaders list tmp = Evaluate( "@replacesubstring('"+ Parties +"'; ';' ; ',')") subtitle = subTitle + "Assigned to: "+ tmp(0) + "." End If docPrintPreview.subTitle = subtitle 'the next step is needed since the user will need to delete this document once he's printed it. Set authorsItem = docPrintPreview.ReplaceItemValue( "PrintPreview_Authors", session.UserName ) authorsItem.IsAuthors = True %REM '======The following variables are using for sorting purposes (THIS USES EXTERNAL ROUTINES) Redim sortKey(coll.count) As Variant Redim docIds(coll.count) As String For i=1To coll.count Set docSource = coll.getnthdocument(i) sortKey(i) = docSource.agendaitem(0) docIds(i)=Cstr(i) Next Call qsortdocs(sortKey, docIds, 0, coll.count) '======Up to here %END REM 'Now populate the body of the print preview For i = 1 To coll.c

This was first published in November 2000

Dig deeper on Domino Resources - Part 3

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWinIT

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchVirtualDataCentre.co.UK

Close