Dumb question on agent script

I’ve got a dumb question to ask…I have a agent that is set to run on new documents and the selection is in the people folder of names.nsf…

I keep getting Object variable not set on the server console and I figure it’s the set doc or the set item lines… But i just don’t know why.

(for set item… I’ve also tried getFirstItem)…

Dim s As New NotesSession

Dim db As NotesDatabase

Dim doc As NotesDocument

Dim item1 As NotesItem

Dim item2 as NotesItem

Set db = s.Currentdatabase

Set doc = s.DocumentContext

Set item1 = doc.GetItemValue (“FirstName”)

Set item2 = doc.GetItemValue (“LastName”)

Print "User is: " & item1.Text & " " & item2.text

Can anyone tells me why this fails?

I figure I can do a While loop in a DC collection, but I thought when you do a set doc=s.DocumentContext under this type of agent setup,… doc is the current document the agent is running on…and it’s like it’s can’t “see” doc…

Subject: GetItemValue != NotesItem

GetItemValue returns a array of values via a Variant data type.

You have item1 and item2 DIM’ed as NotesItem data types.

Change them to variants, and you should be good to go!

FYI: I would do the following:

Dim s As New NotesSession

Dim doc As NotesDocument

Set doc = s.DocumentContext

Print "User is: " & Join(doc.GetItemValue(“FirstName”), “”) & " " & Join(doc.GetItemValue(“LastName”), “”)

HTH,

-Chris

Subject: still errors

07/22/2010 03:01:20 PM AMgr: Agent (‘SetupNewPerson’ in ‘names.nsf’) error message: Object variable not set

What I’m trying to do is get a handle on the doc (person doc) and I will have to write text values back to the doc…aliases…employee info…etc…

I was hoping if I could get a handle on “doc”, then I could populate the fields…but it appears I can’t even read from it…

Thank you for your time!

(if you have another tip that would be great!)

Subject: You’ll want to use the NotesDocument.UnprocessedDocuments

Dim s As New NotesSessionDim col As NotesDocumentCollection

Dim doc As NotesDocument

Set col = s.Currentdatabase.Unprocesseddocuments

Set doc = col.Getfirstdocument()

Do Until(doc Is Nothing)

'Now that you have the NotesDocument...

Set doc = col.Getnextdocument(doc)

Loop

This should do the trick!

HTH,

-Chris

Subject: That did it

Thanks!..

~Brett