Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting error running an agent, only when on schedule not on menu

Status
Not open for further replies.

portagal

Programmer
Jul 28, 2004
32
CA
I have an agent (writen in LotusScript) when run creates a new doc using a form and along the way it adds new elements to it such as creating new RichTextItem, sections, tables, text...
in one part of the script after i create a new RichTextItem and a section in this item i am appending a table:

Dim mySection As New NotesRichTextItem(newDoc, thename)
Call mySection.BeginSection(theTitle)
Call mySection.AppendTable(numOfRow%, numOfCol%,,,styles)
Call mySection.EndSection
Dim rtNav As NotesRichTextNavigator
Set rtNav = mySection.CreateNavigator
Set rtTable = rtNav.GetFirstElement(RTELEM_TYPE_TABLE ) <--

when run on menu it runs perfectly and does what it is suppose to but when set to run on schedule it gives "Object variable not set" on marked line.

any help would be greatly appreciated
 
A simplified version of my code is as following:

Sub Initialize

On Error Goto ErrorHandler
Dim agentLog As New NotesLog(theLog)

Dim session As New NotesSession
Dim db As NotesDatabase
Dim nview As NotesView
Dim doc As NotesDocument
Dim body As NotesRichTextItem
Dim nrtNav As NotesRichTextNavigator
Dim rtTable As NotesRichTextTable
Dim isSaved As Boolean

Set db = session.CurrentDatabase
Set doc = db.CreateDocument()
Call doc.ReplaceItemValue("form", "ToolIndex")
Call doc.ReplaceItemValue("DocName", "testing")
Set body = doc.CreateRichTextItem("body")
Call body.BeginSection("SVT")
Call body.Appendtable(2,2)
Call body.EndSection
Set nrtNav = body.CreateNavigator
Set rtTable = nrtNav.GetFirstElement(RTELEM_TYPE_TABLE )
rowCount% = rtTable.RowCount
Dim mainbody As New NotesRichTextItem(doc, "mainBody")
Call mainbody.AppendRTItem(body)
isSaved = doc.Save(True, False)

ErrorHandler:
Call agentLog.OpenAgentLog
Call agentLog.LogAction(Err & " " & Erl & " " &Error)
Call agentLog.Close
Resume Next
End Sub

this agent runs without any problem when run manually but when running on schedule it gives "object variable not set"
error on this line: rowCount% = rtTable.RowCount

Thanks,
 
That would seem to indicate that the Set rtTable instruction does not return a table at run time.

The description in the Help database states that : "The navigator maintains a current position. Both find and get operations change the current position in the rich text item"

That sounds suspiciously like UI-only operations. If so, it would mean that you cannot use the RTNavigator in backend agents - and the Help does not say so.

I'll try to find the final word on that.

Pascal.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top