hcl-bot
February 27, 2007, 8:32am
1
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
hcl-bot
February 27, 2007, 9:57am
2
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
hcl-bot
February 27, 2007, 10:27am
4
Subject: RE: Agent to add readers field
Thank you!!! It’s working!!!
Alicia
hcl-bot
February 27, 2007, 8:39am
5
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
hcl-bot
February 27, 2007, 8:57am
6
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?
hcl-bot
February 27, 2007, 9:13am
8
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?
hcl-bot
February 27, 2007, 9:22am
9
Subject: RE: Agent to add readers field
I select the documents in a view.
Thanks!
hcl-bot
February 27, 2007, 10:19am
10
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 )