gpt4 book ai didi

java - 如何使用 Java 脚本将 docID 从一个 NotesDocument 添加到另一个 NotesDocument

转载 作者:太空宇宙 更新时间:2023-11-04 13:55:27 24 4
gpt4 key购买 nike

我有一个 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);
}

参数contactorganization必须是NotesDocument类型。调用该函数后,不要忘记保存联系文档。

关于java - 如何使用 Java 脚本将 docID 从一个 NotesDocument 添加到另一个 NotesDocument,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29874970/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com