Dear collegues
I have a big problem.:
I build one agent to update the current value "nomAntic" (a USERNAME search key) with a new value "nomNou" (A USERNAEM key, both supplied from a INPUTBOX) in all READERS or AUTHORS fields of the document.
The agent runs over a document selection.
For each document (While), I search into all Items (Forall i in doc.items)
and for each Item (IsAuthors or IsReaders), next I search for the occurrence of the suplied USERNAME key into the list values (Forall j in item.Values).
I append the new value into the collection -TextList-,
But How I delete the current collection's value??It's possible to Replace the values in a TextList?
Sub Initialize
Dim ses As New NotesSession
Dim db As NotesDatabase
Dim vw As NotesView
Dim ndc As NotesDocumentCollection
Dim doc As NotesDocument
Dim item As NotesItem
Dim itemName As String
Dim nomAntic As String
Dim nomNou As String
Dim ItemValue As String
Set db = ses.CurrentDatabase
Set ndc = db.UnprocessedDocuments
If ndc.Count = 0 Then
Messagebox "Agent modifica Uname: No s'ha seleccionat cap document, el programa finalitzara la seva execucio"
Exit Sub
End If
nomAntic = Inputbox$("Quin usuari Notes vols substituir?")
nomNou = Inputbox$("Especifica el nou usuari Notes")
If nomAntic = "" Then
Messagebox "Agent modifica Uname: No s'ha triat un usuari per substtiuir, el programa finalitzara la seva execucio"
Exit Sub
End If
If nomNou = "" Then
Messagebox "Agent modifica Uname: No s'ha especiificat cap nou usuari Notes, l'usuari especificat anteriorment sera eliminat"
End If
'Messagebox "Agent modifica Uname :Recorrem tots els document seleccionats"
Set doc = ndc.GetFirstDocument
While Not ( doc Is Nothing)
Forall i In doc.Items
itemName = i.Name
'Messagebox "Processant els valors del Camp : " & ItemName
If (i.IsAuthors Or i.IsReaders) Then
Messagebox "Agent modifica Uname: El camp " & itemName & " es un camp tipus AUTHORS o READERS"
Set item = doc.GetFirstItem(itemName)
Forall v In Item.Values
If v = nomAntic Then
Messagebox "Agent modifica Uname: El camp " & itemName & " conte una entrada amb el nom especificat " & nomAntic
Call item.AppendToTextList( nomNou )
Call Doc.Save(True,True)
Messagebox "Agent modifica Uname: El camp " & itemName & " s'ha afegit una entrada amb el nom especificat " & nomNou
Else
Messagebox "Agent modifica Uname: No s'ha trobat l'usuari especificat en cap camp AUTHORS o READERS del document "
Exit Forall
End If
End Forall
End If
Call doc.Save( True,True)
End Forall
Set doc = ndc.getNextDocument(doc)
Wend
End Sub
Sincerely
Software/Hardware used:
ASKED:
July 7, 2006 9:19 AM
UPDATED:
July 10, 2006 10:01 AM
You could also do this with a one-line Evaluate using @replace. This would eliminate one of your loops.
Using Evaluate in LotusScript to run @Formula code can be extremely powerful and fast.