andyhines
asked on
Readers names via agent in Lotus Notes
Hi,
I have created a field in a Notes document which I have populated with a list of user names and groups. Although I updated the form to include the new field I popoulated my existing documents with an agent and as a consequence the field types are not flagged as Readers, just TEXT LIST.
I therefore ran this agent
Sub Initialize()
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim item As NotesItem
Set db = session.Currentdatabase
Set view = db.getView("Restricted Purchase Orders")
Set doc = view.GetFirstDocument
Do While Not(doc Is Nothing)
Set item = doc.GetFirstItem("Restrict edViewers" )
item.IsNames = True
item.IsReaders = True
Call doc.Save(True,True)
Set doc = view.GetNextDocument(doc)
Loop
End Sub
which fails to update the field types. The field Restricted Viewers still shows as Text List and doesn't have the READERS or NAMES flags against it.
What is the easiest way to accomplish this ?
Thanks - Andy
I have created a field in a Notes document which I have populated with a list of user names and groups. Although I updated the form to include the new field I popoulated my existing documents with an agent and as a consequence the field types are not flagged as Readers, just TEXT LIST.
I therefore ran this agent
Sub Initialize()
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim item As NotesItem
Set db = session.Currentdatabase
Set view = db.getView("Restricted Purchase Orders")
Set doc = view.GetFirstDocument
Do While Not(doc Is Nothing)
Set item = doc.GetFirstItem("Restrict
item.IsNames = True
item.IsReaders = True
Call doc.Save(True,True)
Set doc = view.GetNextDocument(doc)
Loop
End Sub
which fails to update the field types. The field Restricted Viewers still shows as Text List and doesn't have the READERS or NAMES flags against it.
What is the easiest way to accomplish this ?
Thanks - Andy
Your original Agent should have done this to preserve the field type.
Call doc.ReplaceItemValue( "RestrictedViewers" , "NewValue" )
Now you're going to have to put this into an agent to update the fields.
Dim myReaders As NotesItem
Set myReaders = New NotesItem( doc , "RestrictedViewer" , "NewValue", READERS )
If there are multiple values to enter you'll have to build up a list first and put that instead of "NewValue".
Call doc.ReplaceItemValue( "RestrictedViewers" , "NewValue" )
Now you're going to have to put this into an agent to update the fields.
Dim myReaders As NotesItem
Set myReaders = New NotesItem( doc , "RestrictedViewer" , "NewValue", READERS )
If there are multiple values to enter you'll have to build up a list first and put that instead of "NewValue".
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you all for your quick responses. Let me try this on Monday and I'll see how it goes..
Andy
Andy
ASKER
Spot on. Thank you.
ASKER
All answers were correct bu Sjef's gave me the fastest easiest fix. Worked first time. Thank you all...
Get the values from the field, then remove item, save the doc to make sure change is committed, add the new item with is reader set before the save. then finally save the document.
You can change properties of an existing field such as is summary, but cannot change it's type once created.