How to Append Text to a text Field

Hi All,I have a agent which get ACL list of database, I need names of from ACL who are of type person and having manager access, So I created the agent accordingly,

Now the issue is, I want to save these (Multiple) names in a text field, I am finding it difficult to store multiple names as array in text field.

My Code :

Sub Initialize

On Error Goto errHandler

Dim session As New NotesSession

Dim db As NotesDatabase

Dim db2 As NotesDatabase

Dim doc As NotesDocument

Dim view As NotesView

Dim ctr As Integer

Dim AclCtr As Integer

Dim dbname, bpath,server As String	

Dim sessionMgr As New NotesSession

Dim acl As NotesACL

Dim aclentry As NotesACLEntry

Dim nam As NotesName	

Dim ss As String		

Dim x() As String



Set db = session.CurrentDatabase

Set view = db.GetView("vwAll")

Set doc = view.GetFirstDocument

ctr = 0	

Do While Not (doc Is Nothing)

	AclCtr = 0

	dbpath = Cstr(doc.txtPath(0))

	server = Cstr(doc.txtAppOnServer(0))

	Set dbm = session.GetDatabase(server,dbpath,False)		

	Set acl = dbm.ACL

	Set aclentry = acl.GetFirstEntry

	If (ctr > 3) Then

		Exit Do

	End If		

	Do While Not aclentry Is Nothing			

		If (aclentry.Level = 6) Then

			If(aclentry.Isperson) Then		

				If (Instr(aclentry.Name,"Local")) Or (Instr(aclentry.Name,"#") Or (aclentry.Name = "TasmanTemplateManagers") Or (Instr(Lcase(aclentry.Name),"server"))) Then

					Goto nextAclList

				End If		

				Set nam = sessionMgr.Createname(aclentry.Name)

				ss = nam.Common						

				Msgbox "manager is   "+aclentry.Name,64, dbm.Title

                                    ' *******************************************************************

				' I want to save the acl name list here,

                                    ' there are more than one manager in every database

                                    '********************************************************************

				AclCtr = AclCtr + 1					

			End If			

		End If

nextAclList:

		Set aclentry = acl.Getnextentry(aclentry)

	Loop		

	ctr = ctr + 1

	Set doc = view.GetNextDocument(doc)

Loop	

Exit Sub	

errHandler:

Msgbox "Initialize Error on Line >>>>>>>>>>>  " + Cstr(Erl) + ":" + Chr(10) +Cstr(Error$)

End Sub


Please guide me

Thanks in Advance

Subject: Multi-value text field

I will assume that the field where you want to store the manager names is defined as a multi-value text field.

The only thing you need to do is to build an array in your loop, containing the names of the managers (in this case).

Remember, doing a redim and extending the array for each additional entry is a very expensive call, so if you know the size if the array beforehand, that is a big benefit.

What I would do is to add the names to a temporary list, and at the same time increase a counter so you know the number of elements in the list.

Dim manager List As String

Dim userArray(0) As String

In your loop:

cnt = cnt + 1

manager(Cstr(cnt)) = aclentry.Name

Then, after you exit the first loop, you dimension the array to the correct size and perform a ForAll on the list to move the values to the array:

Redim userArray(cnt-1) As String

Forall m in manager

userArray(Cint(ListTag(m))) = m

End ForAll

Finally you write the value to the field:

Call doc.ReplaceItemValue(“YourFieldName”,userArray)

That is how I would do it.

Also, I notice this line in your code:

Dim dbname, bpath,server As String

That would declare dbname and bpath as Variant, not as String as I assume you want. You need to explicitly declare the data type of each variable.

Also, try to avoid using Goto, I see that you used that in your code, but you could achived the sam ething without using a Goto there…

Subject: Thanks Karl

Hi Karl,Thanks for guiding, I will do according to your Suggestions and will let you know soon.

Thanks once again