PDF Export from Lotus Domino: DominoPDF For Major Nigeria FMCG Company Workflow Management System

Samuel Obe of Nubiaville Nigeria Limited talks about their implementation of a workflow management system using Lotus Notes Domino and DominoPDF for an FMCG company with offices across the West Africa Area. He details his technical selection criteria for a PDF solution for Lotus Domino and shares some sample code for other developers.

Invoices

Our client needed to stop processing physical invoices and start receiving all invoices via email. One of the fallouts of that is the need to issue an Electronic Transaction Authorisation Note (ETA) before invoices without an initial purchase order can be sent in.  This ETA Note will then be attached to the invoice and sent via email to our client's invoice mail box before the invoice can be paid. This only applies to invoices without an initial Purchase Order (For things like hotel bills, utilities, basic repairs, etc.).

During the period of processing of physical invoices, an invoice can either be sent directly to the project manager or dropped at the gate.  This created a lot of problems since invoices got missed and this affected the 30 day payment timeline, making our clients look bad to suppliers.
With the electronic submission of invoices, the aspect of the project manager and all the necessary stake holders vetting and approving an invoice before it was paid became a big problem. The only way to handle this was to create an ETA Note request process.

When a project is complete, the project manager initiates an ETA Note request informing all the stake holders that the project is complete. Information such as cost centre, amount, description of the work done, etc. is entered on the ETA form and the form is sent to the budget holder for approval.

Once it has been approved, the ETA note is sent to the vendor and the vendor can attach it to the invoice before sending it for payment.

Approved Travel Itinerary

One of the request forms on the intranet portal is a travel ticket request form. The travel ticket request form is used by staff intending to travel for official trips to raise a travel ticket request that will be sent to a travel agency as the approved travel Itinerary. The travel agency then uses this information for booking of the travel ticket.

When an employee wants to travel, he sends a mail to the travel agency informing them of the date, time and location of travel. The travel agency then sends back three different itineraries with cost, times and other information.

The employee then raises a travel ticket request and populates it with the three different itineraries. He selects the one that best suits him and the company and sends it for approval. Once the request has been approved, the agency gets the details as a pdf file with the selected one marked. They then use that request for purchasing the travel ticket

Recognition Voucher Generation

The companies staff recognition request form is a form on the intranet portal that manages recognition of excellence of employees by other employees. When an employee is nominated for recognition, he gets an electronic voucher.

To redeem the voucher, various gift items from various vendors have been pre-loaded into the system. He selects the gift item he wants to redeem and a pdf containing the item and his details is automatically sent to the vendor and a copy sent to him so he can print and take to the vendor.

Selecting a solution for PDF from Lotus Domino: Considerations and our Findings

The PDF generating tool initially looked into was PDF creator. This is a COM based PDF generating tool. One of the obstacles was that it can only convert an existing file, so for me to use this I had to generate an html or Word file and then run the PDF creator code to convert the file. This is a really tedious process since I had to check if the file has been created, send the thread to sleep for a few seconds, convert the file to PDF, before I attach it and mail.

Also when I have to run through a long list of supporting documents, it becomes a problem since I must have a fresh file generating code before I have a PDF generating code.

With DominoPDF, once I have created the form, I can either use the link of the form to generate the PDF or create another form for printing.

The print form has all the same fields as the request form but the information is formatted for reporting than for document entry.

Lotus Notes to PDF Generation: Sample Agent Code

Declare Function DoPDF Lib "DOMINOPDF.DLL" (ByVal szInput As String, ByVal szOutput As String,
ByVal szOptions As String) As Long
Sub Initialize
            
            Dim sDirectory, sOptions As String
            Dim iRet As Integer
            Dim rt As NotesRichTextItem
            Dim object As NotesEmbeddedObject
            Dim rdoc, pdfdoc,webdoc As NotesDocument
            Dim s As NotesSession
            Dim db As NotesDatabase
            Dim view As NotesView
            Dim item As NotesItem
            Dim pdfpath,pdfFile,vendorEmail,projectName As String
            Dim dbname,action,vFilename As Variant
            Dim arg,urlparams,requestId As String
            On Error GoTo ProcessError
            
            Dim vEval As variant
            
     
            Set s = New NotesSession
            Set webdoc = s.DocumentContext
            Set db = s.CurrentDatabase
            arg  = webdoc.Query_String_Decoded(0)
            
            UrlParams=ExtractUrlParams(arg)
            
            RequestId=UrlParams(1)
            
            Set view = db.GetView("WebRequests")
            
            Set pdfdoc= view.GetDocumentByKey(RequestId)
            dbname=Evaluate("@LowerCase(@WebDbName)")
            pdfpath="http://10.131.248.12/"+dbname(0) + "/printview/" + pdfdoc.UniversalID +
"?openDocument"
            sDirectory = "C:\DOMINOPDF\"
            vFilename = Evaluate(|@Right(@Unique;"-")|)     
            pdfFile = sDirectory & "DOM" & vFilename(0) & ".pdf"

            Call DoPDF(pdfpath, pdfFile,"WebUsername=emaployeename;
Webpassword=employee password;LeftMargin=15;RightMargin=15;TopMargin=15;BottomMargin=15")
            vendorEmail=pdfdoc.vendorEmail(0)
            ProjectName=pdfDoc.projectName(0)
            Set rdoc = New NotesDocument(db)
            
            rdoc.form = "Memo"
            rdoc.subject = " Electronic Transaction Authorisation Note For "+ProjectName+
" From Company"
            Set rt = New NotesRichTextItem (rdoc , "Body" )
            Call rt.addnewline(2)
            Call rt.appendtext("Please find attached the Electronic Transaction
Authorisation Note ")
            Set object = rt.EmbedObject( EMBED_ATTACHMENT, "", pdfFIle)
            Call rt.addnewline(2)
            rdoc.sendto = VendorEmail
            Call rdoc.send(True)
            
            Print "ETA Note has been sent to " & VendorEmail & ".    <a href='/" +dbname(0) +
"/All+Requests?OpenView'>CLICK HERE to close this window</a>"

            Exit Sub
            
ProcessError:
            Print "<br>Code Sub: generatePDF, Error Description: " Error(),
"   Err Code:" Err(), "   Err Line:" Erl()
            Exit Sub
End Sub
Function ExtractUrlParams(QStr)
            Dim arg As Variant
            Dim iCount As Integer
            
            arg=Split(QStr,"&")
            
            For iCount=1 To UBound(arg)
                        arg(iCount)=Mid$(arg(iCount),InStr(arg(iCount),"=")+1)
            Next
            ExtractUrlParams=arg
End Function

Some specific tips and techniques to Print or PDF from Lotus Notes

To cause the document to open in the print form and not the document entry form, a print view is created with the following formula in the “Form Formula”.

@if(Form="ETA Note";"PrintETA";@if(Form="Travel Ticket";"PrintTravel";
@if(Form="Recognition";"Voucher")))

This tells the print view to use the PrintETA form where the document was created with the ETA Note form and PrintTravel where the document was created with the Travel Ticket form and Voucher where the document was created with the Recognition form.

This way, to add another form I just add another if statement to the form formula, create a data entry form and a print form.

Also, since there are a lot of other forms in the portal to prevent every request from generating a PDF file, I created a field called printPDF. Any document that has a printPDF field will be generated as a PDF and sent to the vendorEmail field.

Finally a resend PDF link is included so that if there is a need to resend the PDF a user can just click on the resend PDF action and the PDF will be resent to the vendor.

About the Author

Samuel Obe is the CEO of Nubiaville Nigeria Limited. Nubiaville Nigeria Limited is a Nigerian based IT consulting company with focus on web applications, mobile applications and embedded applications development.

Comments are closed.