Obj Var Not Set When running agent on server; OK on Local

I have just written an agent that works perfectly when run locally but when I move it to the server I get “Object Variable Not Set”

Here’s my code:

Class Product

Public type As String

Public name As String

Public state As String

Public mktcompany As String

Public newavailstate List As String

Public availcomments List As String

Public newexception List As String

Public unid As String

Public myRef As Product ’ Reference to an object of this class

End Class

Sub Initialize

Dim session As New NotesSession

Dim db As NotesDatabase

Dim dc As NotesDocumentCollection

Dim doc As NotesDocument

Dim maildoc As NotesDocument

Dim searchString As String, lastmonth As String

Dim rtStyle1 As NotesRichTextStyle

Dim rtStyle2 As NotesRichTextStyle

Dim rtStyle3 As NotesRichTextStyle

Dim rtStyle4 As NotesRichTextStyle

Dim rtStyle5 As NotesRichTextStyle

Dim rtStyle6 As NotesRichTextStyle

Dim rtStyle7 As NotesRichTextStyle

Dim arr_States As Variant

Dim arr_PMStateAvail

Redim arr_PMStateAvail(0)

arr_PMStateAvail(0) = “”

Dim arr_PMStateAvailDates

Redim arr_PMStateAvailDates(0)

arr_PMStateAvailDates(0) = “”

Dim arr_CommentsAvail

Redim arr_CommentsAvail(0)

arr_CommentsAvail(0) = “”

Dim arr_ExceptionAvail

Redim arr_ExceptionAvail(0)

arr_ExceptionAvail(0) = “”

Dim tmp As Variant

Dim availDate As NotesDateTime

Dim eDate As NotesDateTime

Dim availExcept As String

Dim tempComment As NotesItem

Dim tempException As NotesItem

Dim arr_Comments() As String

Dim arr_Exception() As String

Redim Preserve arr_Comments(0) As String

Redim Preserve arr_Exception(0) As String

arr_Comments(0) = “”

arr_Exception(0) = “”

Dim commentItem As String

Dim exceptionItem As String

Dim stravailDate As String

Dim PMBegDate As NotesDateTime

Dim PMEndDate As NotesDateTime

Dim item As NotesItem, itemE As NotesItem, rtitem As NotesRichTextItem

Dim AnyProductAvail As Integer, AnyStateAvail As Integer, i As Integer, Yr As String, statecnt As Integer

Dim doccount As Integer, prodcount As Integer

Dim prod List As Product 'user defined class

Dim endingdate As String, themonth As String

Dim blnUseEDate As Integer

Dim j As Integer

j = -1

Set session = New NotesSession

Set db = session.currentdatabase

'get StateApproval documents

searchString = { Form=“StateApprovals” }

Set dc=db.search( searchString, Nothing, 0)

If dc.Count=0 Then Exit Sub

arr_States = Evaluate( { @DbColumn(“”:“”; @DbName; “(States)”; 1) } ) 'load all of th estates into the array

’ tmp=Evaluate( { @Adjust(@Date(@Year(@now);@Month(@now); 1;0;0;0); 0;-1;0;0;0;0) }) 'Beginning of last month

’ tmp=Evaluate( { @Adjust(@Date(@Year(@now);@Month(@now); @Day(@now);0;0;0); 0;0;-7;0;0;0) }) 'Beginning of last month

tmp=Evaluate( { @Adjust(@Date(@Year(@now);@Month(@now); @Day(@now);0;0;0); 0;0;-30;0;0;0) }) 'FOR TESTING ONLY

Set PMBegDate = New NotesDateTime( tmp(0) )

’ tmp=Evaluate( { @Adjust(@Date(@Year(@now);@Month(@now); 1;0;0;0); 0;0;0;0;0;-1) }) 'Last second of last month

tmp=Evaluate( { @Adjust(@Date(@Year(@now);@Month(@now); @Day(@Now);0;0;0); 0;0;0;0;0;-1) }) 'Last second of last month

Set PMEndDate = New NotesDateTime( tmp(0) )

'Set up styles … we like colors!

.

.

.

Set maildoc = New NotesDocument(db)

maildoc.form = “Memo”

Set rtitem = New NotesRichTextItem( maildoc, “Body”)

Call rtitem.AppendText(“The following products became available in the past week:” )

AnyProductAvail = False

doccount = -1

Set doc=dc.GetFirstDocument

While Not(doc Is Nothing)

AnyStateAvail = False  'State Within this Product document

For i=0 To Ubound(arr_States)

Set item = doc.GetFirstItem( "Pdate_" & Cstr(i) )

	Set tempComment = doc.GetFirstItem("Comments_" & Cstr(i) )

	Set tempException = doc.GetFirstItem("Exception_" & Cstr(i) )

		

	commentItem = tempComment.Text

	exceptionItem = tempException.Text    <== This is where I fail with "Object variable not set"

In debug, I cannot see the exception field; tehrefore, tempexception is nothing.

What is causing this to happen on the server when it runs locally? I am using the same document to test with on both databases. The db ACLs are the same also.

Thanks in advance.

Subject: Obj Var Not Set When running agent on server; OK on Local

Mary,

What kind of field is ExceptionX? Is it editable, computed when composed, computed or computed for display? If it’s the last one, you will always get this error.

Brandt

Subject: RE: Obj Var Not Set When running agent on server; OK on Local

Brandt,

It’s a radio button field, editable.

Subject: Fixed the problem…

turns out that whoever added the exception field in the first place did not initialize or set the value to any value. That’s why it wasn’t recognizing it and causing the error.

Thanks for your help.