Object Variable not set? Web agent

Thanks to everyone who has contributed so far, and thanks for your patience as I learn. This is the script that I generated, but on debugging, I get a “Object Variable not set” on the Set dc line. I thought I already set it at the top of the statement? Looking through this and dozens of threads, I can’t get this resolved. This is part of the web query save.

Sub initialize

Dim session As New NotesSession

Dim db As NotesDatabase	

Dim doc As notesdocument

Dim dc As NotesDocumentCollection

Set db = session.CurrentDatabase

Set view = db.GetView( "TaskMeetingChangeState" )

Set doc = session.DocumentContext

Set dc = view.GetAllDocumentsByKey(doc.GetItemValue("OriginalREF"), False)

If Not dc Is Nothing Then	

	Call dc.StampAll("State", doc.GetItemValue("State"))

End If

End Sub

Subject: Object Variable not set? Web agent.

You declared the dc, which just tells Notes to set up a variable by that name and type. You don’t actually give it a value until the line where the error pops up, which is a different thing altogether. The code looks legal, so there’s probably a problem with either the view or the document you get from the document context. Make sure that a view by that name exists and you do actually get a document with an item named OriginalREF from DocumentContext.

Subject: Object Variable not set? Web agent.

Set dc = view.GetAllDocumentsByKey (Cstr(doc.OriginalREF(0)),False)

Subject: Object Variable not set? Web agent.

Check for the accuracy of the view name that you’re trying to set here:

Set view = db.GetView( “TaskMeetingChangeState” )

Is the name correct? Is the view hidden - so maybe you need parentheses around the name? Is the view hidden from web browsers?

Subject: Object Variable not set? Web agent.

Phillipe,

have you checked that view “TaskMeetingChangeState” is correctly typed (correct case as well)?

Is it a hidden view - if so it should be “(TaskMeetingChangeState)”

Does the document have field OriginalREF?

worth trying is the following for debug purposes:

Sub initialize

Dim session As New NotesSession

Dim db As NotesDatabase	

Dim doc As notesdocument

Dim dc As NotesDocumentCollection

Set db = session.CurrentDatabase

Set view = db.GetView( "TaskMeetingChangeState" )

MSGBOX view.title

Set doc = session.DocumentContext

MSGBOX doc.OriginalREF(0)

Set dc = view.GetAllDocumentsByKey(doc.GetItemValue("OriginalREF"), False)

If Not dc Is Nothing Then	

	Call dc.StampAll("State", doc.GetItemValue("State"))

End If

End Sub

hope thats of some help … John Kvalheim

Subject: RE: Object Variable not set? Web agent.

MSGBOX view.title

This is an agent run from the web, so probably print rather than msgbox.

Say, that might be an issue. If he’s testing in a client rather than on the web, wouldn’t there be a problem with DocumentContext?

Subject: RE: Object Variable not set? Web agent.

I missed that entirely. That is exactly the root cause of his problem.

Great catch!

Subject: RE: Object Variable not set? Web agent.

That’s it (hidden view)!! I thought that lotusscript followed the convention of using aliases like the client does, but apparently it does not. I changed the view to “(TaskMeetingChangeState)” and it works!

Thanks to all who contributed.

Subject: RE: Object Variable not set? Web agent.

It does use aliases… check for spelling, spaces, etc in your alias.