SFormula = {Form = "OfficeMemo" & Status = "Send" & IO_IntCorrPers ="}+Cstr(ioDoc.GetItemValue("PName")(0))+{|}+Cstr(ioDoc.GetItemValue("PUNID")(0))+{"}
Set docColl = db.Search (SFormula, Nothing, 0)
Set doc= docColl.GetFirstDocument
While Not doc Is Nothing
i=0
Forall IO_IntCorrPer In doc.GetItemValue("IO_IntCorrPers")
If Debug Then Print "Данные персоны в списке: " + Cstr(IO_IntCorrPer)
If IO_IntCorrPer=Cstr(ioDoc.GetItemValue("PName")(0))+"|"+Cstr(ioDoc.GetItemValue("PUNID")(0)) Then
iElementNum=i
End If
i=i+1
End Forall
If iElementNum=0 Then
Call doc.ReplaceItemValue("CorrNameProxy",ioDoc.GetItemValue("IOName")(0))
Else
Redim aAddressee (Ubound(doc.GetItemValue("CorrNameProxy")))
For i=0 To Ubound(doc.GetItemValue("CorrNameProxy"))
If i= iElementNum Then
aAddressee (i)=ioDoc.GetItemValue("IOName")(0)
Else
aAddressee (i)=doc.GetItemValue("CorrNameProxy")(i)
End If
Next
Call doc.ReplaceItemValue("CorrNameProxy",aAddressee)
End If
Call doc.ReplaceItemValue("CorrNameProxy", Cstr(ioDoc.GetItemValue("IOName")(0)))
Call doc.ReplaceItemValue("CorrNameProxyLN", Cstr(ioDoc.GetItemValue("IONotesName")(0)))
Call doc.GetFirstItem ("CorrNameProxyLN").AppendToTextList (ioDoc.GetItemValue("IONotesName")(0))bChangeOrNot=True
i=0
quantity=Ubound(doc.GetItemValue("WriteAccess"))
Redim aNotesPersonWA (quantity)
Forall NotesPersonWA In doc.GetItemValue("WriteAccess")
aNotesPersonWA(quantity- quantity +i)=NotesPersonWA
If Cstr(iodoc.IONotesName(0))=NotesPersonWA Then
bChangeOrNot=False
End If
i=i+1
End Forall
If bChangeOrNot Then
Redim Preserve aNotesPersonWA (quantity+ 1)
aNotesPersonWA (quantity+ 1) = Cstr(iodoc.IONotesName(0))
Call doc.ReplaceItemValue("WriteAccess", aNotesPersonWA)
End If
Call doc.GetFirstItem ("WriteAccess").AppendToTextList (ioDoc.GetItemValue("IONotesName")(0))
Call doc.Save(True, False)