Subject: RE: How to append new roles into readers field
If you are just adding a single fixed value, such as “[Developer]” in this example, you’re probably better off using the AppendToTextList method as it requires far less code.
Dim item As notesitem
Set item = doc.GetFirstItem(“ReadersFieldName”)
Call item.appendtotextlist(“[Developer]”)
Call doc.Save(True, False)
This will add Developer to the existing values in the Readers Field.
If you are needing to add in all of the user’s roles instead of fixed values, you would need to get hold of those in an array, then use ArrayAppend to merge the array with the existing field values into a new array. Next, set the readers field value to be that of the new array.
%REM
Get hold of user roles - there are a number of methods you could use for this.
Evaluating @UserRoles should work if this is a Notes Client Application, but I haven’t really tested it so use another
method if it doesn’t - i.e. the NotesACLEntry class Roles property or something like that
%END REM
Dim f$
Dim roles As Variant
f$ = “@UserRoles”
roles = Evaluate(f$)
Dim returnArray
'Populate Return array with current readers field values and new roles array
returnArray = Arrayappend (doc.ReadersFieldName, roles)
doc.ReadersFieldName = Fulltrim(returnArray)
Call doc.save(True, False)
p.s. Code above is not tested, so may not work as it is, but should serve as a guideline.
Hope it helps.