เคยมั้ยครับ ที่ เอาชื่อไปผูกกับ roles ของ document นั้นๆ แล้ว วันหน้าเกิด มีคนเปลี่ยนนามสกุล คนคนั้นก็เลยเปิด document นั้นไม่ได้เลย
ผมมีวิธีแก้ครับ เอา code ไปเลย ไปสร้าง agent ไว้ update ในแต่ละ document กัน อ้อ ลืมบอก
อย่าลืม ทำ agent ให้ run แบบ share แล้ว on event เป็น แบบ "Action menu select"
target เป็น "All Select document"
script:
'... Create agent for run all document selection
Sub Initialize
Dim ChangeFrom As String, ChangeTo As String
ChangeFrom = "CN=Name1/O=Company"
ChangeTo = "CN=Name2/O=Company"
Dim s As New NotesSession
Dim dc As NotesDocumentCollection
Set dc = s.CurrentDatabase.UnprocessedDocuments
If dc.Count = 0 Then Exit Sub
Dim v As Variant, index As Integer, NeedSave As Integer
Dim doc As NotesDocument
Set doc = dc.GetFirstDocument
While Not doc Is Nothing
NeedSave = False
Forall f In doc.Items
If Left$(f.Name, 1) <> "$" And (f.Type = 1074 Or f.Type = 1075 Or f.Type = 1076)Then
If f.Contains(ChangeFrom) Then
v = f.Values
For index = Lbound(v) To Ubound(v)
If v(index) = ChangeFrom Then
v(index) = ChangeTo
End If
Next
Call doc.ReplaceItemValue(f.Name, v)
NeedSave = True
End If
End If
End Forall
If NeedSave = True Then
Print "saving # " & doc.Title(0)
Call doc.Save(True, False)
End If
Set doc = dc.GetNextDocument(doc)
Wend
Print "Completed"
End Sub |