Lotus Notes Вычитать коллекцию из другой коллекции не работает - PullRequest
0 голосов
/ 03 апреля 2020

Пожалуйста, кто-нибудь может мне помочь В Lotus Notes Вычитание из другой коллекции не работает. и счетчик коллекций dc1 и dc2 работает, но не может вычесть dc1 из dc2

Это дает

Ошибка 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

1 Ответ

1 голос
/ 03 апреля 2020

Вычитаемая коллекция должна находиться в вычитаемой коллекции.

Попробуйте:

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

Хотя существует вероятность бесконечного l oop, если первое сделать c в dc1 никогда не вычитается из коллекции dc1. Вероятно, есть лучший способ сделать это. Ошибка возникает с первой попытки или после? Непрерывное вычитание из dc1 с последующим повторным клонированием dc2 также может вызывать ошибки.

...