如何使用 Java 脚本将一个 NotesDocument 的 docID 添加到另一个
How to add a docID from one NotesDocument to another using Java Script
我有一个 Lotus 脚本,可以将组织 docID 添加到 contactDoc,它工作正常,但我想在 java 脚本
中实现它
Sub AddContactID(contact As NotesDocument, organisation As NotesDocument)
contact.TmpIDString = organisation.DocID(0)
Dim tmp As Variant
tmp = |@SetField("ContactOrganisationIDs";@Trim(@Unique(ContactOrganisationIDs:TmpIDString)))|
Dim flag As Variant
flag = Evaluate(tmp,contact)
Dim Item As NotesItem
Set Item = contact.GetFirstItem("TmpIDString")
If Not (Item Is Nothing) Then
Call Item.Remove
End If
End Sub
反向函数:
Sub RemoveOrganisationIDByID(contactDocId As String, organisation As NotesDocument)
Dim Session As New NotesSession
Dim CurrDb As NotesDatabase
Set CurrDb = Session.CurrentDatabase
Dim contact As NotesDocument
Set contact = CurrDb.GetDocumentByUNID(contactDocId)
If contact Is Nothing Then Exit Sub
If organisation Is Nothing Then Exit Sub
Dim ContactOrganisationIDs As Variant
ContactOrganisationIDs = contact.ContactOrganisationIDs
pos = ArrayGetIndex(ContactOrganisationIDs, organisation.DocID(0))
If Not IsNull(pos) Then
ContactOrganisationIDs(pos) = ""
Call contact.ReplaceItemValue("ContactOrganisationIDs",FullTrim(ContactOrganisationIDs))
Call contact.Save(True, False)
End If
End Sub
下面的 SSJS 函数应该可以做到
function addContactID(contact, organisation) {
contact.replaceItemValue("TmpIDString", organisation.getItemValueString("DocID"));
session.evaluate('FIELD ContactOrganisationIDs := @Trim(@Unique(ContactOrganisationIDs:TmpIDString)); FIELD TmpIDString := @DeleteField; ""', contact);
}
参数 contact
和 organisation
必须是 NotesDocument
类型。调用函数后不要忘记保存联系人文档。
我有一个 Lotus 脚本,可以将组织 docID 添加到 contactDoc,它工作正常,但我想在 java 脚本
中实现它Sub AddContactID(contact As NotesDocument, organisation As NotesDocument)
contact.TmpIDString = organisation.DocID(0)
Dim tmp As Variant
tmp = |@SetField("ContactOrganisationIDs";@Trim(@Unique(ContactOrganisationIDs:TmpIDString)))|
Dim flag As Variant
flag = Evaluate(tmp,contact)
Dim Item As NotesItem
Set Item = contact.GetFirstItem("TmpIDString")
If Not (Item Is Nothing) Then
Call Item.Remove
End If
End Sub
反向函数:
Sub RemoveOrganisationIDByID(contactDocId As String, organisation As NotesDocument)
Dim Session As New NotesSession
Dim CurrDb As NotesDatabase
Set CurrDb = Session.CurrentDatabase
Dim contact As NotesDocument
Set contact = CurrDb.GetDocumentByUNID(contactDocId)
If contact Is Nothing Then Exit Sub
If organisation Is Nothing Then Exit Sub
Dim ContactOrganisationIDs As Variant
ContactOrganisationIDs = contact.ContactOrganisationIDs
pos = ArrayGetIndex(ContactOrganisationIDs, organisation.DocID(0))
If Not IsNull(pos) Then
ContactOrganisationIDs(pos) = ""
Call contact.ReplaceItemValue("ContactOrganisationIDs",FullTrim(ContactOrganisationIDs))
Call contact.Save(True, False)
End If
End Sub
下面的 SSJS 函数应该可以做到
function addContactID(contact, organisation) {
contact.replaceItemValue("TmpIDString", organisation.getItemValueString("DocID"));
session.evaluate('FIELD ContactOrganisationIDs := @Trim(@Unique(ContactOrganisationIDs:TmpIDString)); FIELD TmpIDString := @DeleteField; ""', contact);
}
参数 contact
和 organisation
必须是 NotesDocument
类型。调用函数后不要忘记保存联系人文档。