Link to home
Start Free TrialLog in
Avatar of andyhines
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("RestrictedViewers")
            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
Avatar of doninja
doninja
Flag of United Kingdom of Great Britain and Northern Ireland image

Get the agent to recreate the field from scratch instead of modifying the existing field

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.
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".
ASKER CERTIFIED SOLUTION
Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of andyhines
andyhines

ASKER

Thank you all for your quick responses. Let me try this on Monday and I'll see how it goes..

Andy
Spot on. Thank you.
All answers were correct bu Sjef's gave me the fastest easiest fix. Worked first time. Thank you all...