首页 > 解决方案 > Lotus notes 从另一个不工作的集合中减去集合

问题描述

请任何人都可以帮助我在 Lotus notes 从另一个不工作的集合中减去集合。dc1 和 dc2 收集计数都在工作,但无法从 dc2 中减去 dc1

它在给

错误 4336 方法参数的对象类型无效 在行:调用 dc2.Subtract(dc1)

请找到代码:

Sub sendNotificationAppOwnerMerged(coll As NotesDocumentCollection)

    On Error GoTo errorhandler  
    Dim sess As NotesSession
    Dim db As NotesDatabase
    Dim dc1 As NotesDocumentCollection
    Dim dc2 As NotesDocumentCollection
    Dim doc As NotesDocument
    Dim query As String

    If coll.Count = 0 Then Exit Sub
    Set dc2= coll.Clone()

    Set doc = dc2.GetFirstDocument
    While Not doc Is Nothing    
        Set doc = dc2.GetFirstDocument
        query = | Field SATTEAMNAME = "| & doc.SATTeamName(0) & |"|
        Set dc1= dc2.Clone()    
        Call dc1.Ftsearch(query, 0)
        MsgBox dc2.count
        MsgBox dc1.count
        ' send email to all apps in dc1
        MsgBox "Mail Sent to " + doc.SATTeam(0)

        Call dc2.Subtract(dc1)

        If dc2.count = 0 Then Exit Sub
    Wend

    Exit Sub
errorhandler:   
    MessageBox "Error" & Str(Err) & ": " & Error$   & "On Line " & cstr(Erl)
    Exit Sub
End Sub

标签: lotus-noteslotus-dominolotusscriptlotus

解决方案


要减去的集合必须在要减去的集合中。

尝试:

Sub sendNotificationAppOwnerMerged(coll As NotesDocumentCollection)
    On Error GoTo errorhandler  
    Dim sess As NotesSession
    Dim db As NotesDatabase
    Dim dc1 As NotesDocumentCollection
    Dim dc2 As NotesDocumentCollection
    Dim doc As NotesDocument
    Dim query As String

    If coll.Count = 0 Then Exit Sub

    Set dc1= coll.Clone()

    Set doc = dc1.GetFirstDocument
    While Not doc Is Nothing    
        query = | Field SATTEAMNAME = "| & doc.SATTeamName(0) & |"|
        Set dc2= dc1.Clone()
        Call dc2.Ftsearch(query, 0)
        MsgBox dc2.count
        MsgBox dc1.count
        ' send email to all apps in dc1
        MsgBox "Mail Sent to " + doc.SATTeam(0)

        Call dc1.Subtract(dc2)

        If dc1.count = 0 Then Exit Sub
        Set doc = dc1.GetFirstDocument
    Wend

    Exit Sub
End Sub

虽然如果 dc1 中的第一个 doc 从未从 dc1 集合中减去,则可能会出现无限循环。可能有更好的方法来做到这一点。错误发生在第一次尝试还是之后?不断从 dc1 中减去然后重新克隆 dc2 也可能会导致错误。


推荐阅读