Mark Corrigan
Mark Corrigan

Reputation: 61

Lotus Script Agent not working on Domino 9 server

I have an export to Excel agent that works great on my old 8.5 server. When I moved the database to a 9.0.1 server, the agent only exports one line at a time. If there are 30 lines in the view, you have to run the agent 30 times. What is different on a Domino 9 that would stop the agent from running through each line in the view?`Sub WriteViewasExcel (view As NotesView)

%REM
Agent ExporttoExcel
Created Mar 11, 2010 by Brian Moore/usr/nbt
Description: Comments for Agent
%END REM
Option Public
Option Declare

Sub Initialize()
    Dim s As New NotesSession
    Dim db As NotesDatabase
    Dim qs As NotesView
    Dim nv As NotesViewNavigator
    Dim ne As NotesViewEntry
    Dim Doc As NotesDocument    
    Set db = s.Currentdatabase
    Set qs = db.GetView("Export")
    Set nv = qs.CreateViewNav
    Set ne = nv.GetFirst
    Dim filename As String

    Print |Content-Type:application/vnd.ms-excel|
    filename="Excel "+db.Title+" "+Format(Now, "yyyy-mmm-d hhmm")+".xls" 'file name which will be suggested to user to save the resulting Excel file 
    Print |Content-Disposition: Attachment; filename="|+filename+|"| 'Triggers the save/open browser prompt instead of embedding the spreadsheet in the browser
    Print ""

    Print |<table border="1"><tr>
        <td width="135"> <Center><b>Store Name</td></b>
        <td width="80"> <Center><b>Date</td></b>
        <td width="80"> <Center><b>Nontax clothing sales</td></b>
        <td width="80"> <Center><b><font color="blue">Tax textile sales</td></b></font> 
        <td width="80"> <Center><b><font color="red">Furniture Sales</td></b></font> 
        <td width="80"> <Center><b><font color="green">Elec/Mech Appl/Fixture Sales</td></font> </b>
        <td width="80"> <Center><b> Shoe Sales</td></b>
        <td width="80"> <Center><b><font color="blue">Wares Sales</td></b></font> 
        <td width="80"> <Center><b><font color="red">Total Discounts</td></b></font> 
        <td width="80"> <Center><b><font color="green">Taxable Income</td></font> </b>
        <td width="80"> <Center><b>Tax Amount</td></b>
        <td width="80"> <Center><b><font color="blue">Credit Total</td></b></font> 
        <td width="80"> <Center><b><font color="red">Payout Total</td></b></font> 
        <td width="80"> <Center><b><font color="green">Actual Deposit</td></font> </b>
        <td width="80"> <Center><b>MC/VISA Sales</td></b>
        <td width="80"> <Center><b><font color="blue">AMEX Sales</td></b>
        <td width="80"> <Center><b><font color="red">Gift Certificates</td></b>
        <td width="80"> <Center><b>Customer Count</td></b>
        <td width="80"> <Center><b>Total Donations</td></b></font></Center>
        </tr>|

    While Not(ne Is Nothing)

        Set doc = ne.Document 
        Call doc.ReplaceItemValue("exported" , "yes")
        Call doc.Save(True, False)

        Print|<tr> <td>| + ne.ColumnValues(0) + |</td> | 'Store Name
        Print|<td> | + ne.ColumnValues(1) + | </td> | 'Date
        Print|<td> | + ne.ColumnValues(2) + | </td> | 'Non Tax Clothing Sales
        Print|<td> <font color="blue">| + ne.ColumnValues(3) + | </font> </td> | 'Taxable Textile Sales
        Print|<td> <font color="red">| + ne.ColumnValues(4) + | </font> </td> | 'Furniture Sales
        Print|<td> <font color="green">| + ne.ColumnValues(5) + | </font> </td> | 'Elec/Mech Appliance/Fixture Sales
        Print|<td> | + ne.ColumnValues(6) + | </td> | 'Shoe Sales
        Print|<td> <font color="blue">| + ne.ColumnValues(7) + | </font> </td> | 'Wares Sales
        Print|<td> <font color="red">| + ne.ColumnValues(8) + | </font> </td> | 'Total Discounts
        Print|<td> <font color="green">| + ne.ColumnValues(9) + | </font> </td> | 'Taxable Income
        Print|<td> | + ne.ColumnValues(10) + | </td> | 'Tax Amount
        Print|<td> <font color="blue">| + ne.ColumnValues(11) + | </font> </td> | 'Credit Total
        Print|<td> <font color="red">| + ne.ColumnValues(12) + | </font> </td> | 'Payout Total
        Print|<td> <font color="green">| + ne.ColumnValues(13) + | </font> </td> | 'Actural Deposits
        Print|<td> | + ne.ColumnValues(14) + | </td> | 'MC/VISA Sales
        Print|<td> <font color="blue">| + ne.ColumnValues(15) + | </font> </td> | 'AMEX Sales
        Print|<td> <font color="red">| + ne.ColumnValues(16) + | </font> </td> | 'Gift Certificates
        Print|<td> <font color="red">| + ne.ColumnValues(17) + | </font> </td> | 'Customer Count
        Print|<td> <font color="red">| + ne.ColumnValues(18) + | </font> </td> | 'Total Donations

        Set ne = nv.GetNext(ne)
    Wend

End Sub

Upvotes: 0

Views: 257

Answers (1)

Knut Herrmann
Knut Herrmann

Reputation: 30960

Add after the code line

Set qs = db.GetView("Export")

the line

qs.AutoUpdate = False

Your view navigator gets confused when documents get discarded from view while navigator tries to get from entry to entry. qs.AutoUpdate = False prevents all entries in view during agent run.

Upvotes: 2

Related Questions