Agent to add readers field

Hello! I have a problem with an agent to create a readers field.

I created the agent :

Dim doc As NotesDocument

Dim newValues( 1 To 2 ) As String

newValues( 1 ) = “User 1”

newValues( 2 ) = “User 2”

Dim readersItem As New NotesItem(doc, “docReaders”, newValues, READERS)

Call doc.Save( True, True )

When the agent runs, the following error appears:

“Error Creating Product Object”.

Thank you!

Alicia

Subject: Agent to add readers field

Try this out.This should work…

Dim session As New NotesSession

Dim doc As NotesDocument

Set doc = session.DocumentContext

Dim newValues( 1 To 2 ) As String

newValues( 1 ) = "User 1"

newValues( 2 ) = "User 2"

Dim readersItem As New NotesItem(doc, "docReaders", newValues, READERS)

Call doc.Save( True, True )

Subject: RE: Agent to add readers field

Thank you!!! It’s working!!!

Alicia

Subject: RE: Agent to add readers field

Thank you!!! It’s working!!!

Alicia

Subject: Agent to add readers field

Alicia,

You need to create your document, something like this:

dim s as new notessession

dim db as notesdatabase

set db = s.currentdatabase

set doc = db.createdocument

hth,

raphael

Subject: RE: Agent to add readers field

Raphael,

The documents exist, I need to add an readers field to them.

Is it necessary add these sentences?

Thank you very much!

Alicia

Subject: RE: Agent to add readers field

When running the agent, are you using it against selected doc’s in a view, or from within an open document?

Subject: RE: Agent to add readers field

When running the agent, are you using it against selected doc’s in a view, or from within an open document?

Subject: RE: Agent to add readers field

I select the documents in a view.

Thanks!

Subject: RE: Agent to add readers field

If you are running this code in an agent that acts on selected documents in a view, you need a little more code.

Dim session As New NotesSession

Dim db As NotesDatabase

Dim coll As NotesDocumentCollection

Dim doc As NotesDocument

Dim readersItem As NotesItem

Dim newValues( 1 To 2 ) As String

newValues( 1 ) = “User 1”

newValues( 2 ) = “User 2”

Set db = session.CurrentDatabase

Set coll = db.UnprocessedDocument

Set doc = coll.GetFirstDocument

While Not (doc Is Nothing)

Set readersItem = New NotesItem(doc, “docReaders”, newValues, READERS)

Call doc.Save( True, True )

Set doc = coll.GetNextDocument(doc)

Wend

Subject: RE: Agent to add readers field

If you are running this code in an agent that acts on selected documents in a view, you need a little more code.

Dim session As New NotesSession

Dim db As NotesDatabase

Dim coll As NotesDocumentCollection

Dim doc As NotesDocument

Dim readersItem As NotesItem

Dim newValues( 1 To 2 ) As String

newValues( 1 ) = “User 1”

newValues( 2 ) = “User 2”

Set db = session.CurrentDatabase

Set coll = db.UnprocessedDocument

Set doc = coll.GetFirstDocument

While Not (doc Is Nothing)

Set readersItem = New NotesItem(doc, “docReaders”, newValues, READERS)

Call doc.Save( True, True )

Set doc = coll.GetNextDocument(doc)

Wend

Subject: RE: Agent to add readers field

I select the documents in a view.

Thanks!

Subject: Agent to add readers field

Try this out.This should work…

Dim session As New NotesSession

Dim doc As NotesDocument

Set doc = session.DocumentContext

Dim newValues( 1 To 2 ) As String

newValues( 1 ) = "User 1"

newValues( 2 ) = "User 2"

Dim readersItem As New NotesItem(doc, "docReaders", newValues, READERS)

Call doc.Save( True, True )