2017-10-17 218 views
0

我的問題是使用GetAllDocumentByKey獲取包含「keys」的所有文檔是多個鍵但使用下面的代碼的結果無法獲得全部 如有時僅返回2文檔,但它應該返回包含該鍵的文檔。「GetAllDocumentsByKey」無法通過密鑰獲取所有文檔

我應該如何解決這個問題?

Sub Click(Source As Button) 
    Dim workspace As New NotesUIWorkspace 
    Dim session As New NotesSession 
    Dim db As NotesDatabase 
    Dim view As NotesView 
    Dim dc As NotesDocumentCollection 
    Set db = session.CurrentDatabase 
    Dim uidoc As NotesUIDocument 
    Set uidoc = workspace.CurrentDocument 
    Dim doc As NotesDocument 
    Dim keys(0 To 1) As Variant 
    'Dim vc As NotesViewEntryCollection 



    Dim defect As Variant 
    defect = uidoc.FieldGetText("DefectMode") 
    keys(0) =defect 
    Dim PartNo As Variant 
    partNo = uidoc.FieldGetText("PartNo") 
    keys(1) = partNo 

    Set view = db.GetView("EmbedView2") 
    Set dc = view.GetAllDocumentsByKey(keys,False) 
    'Set vc=db.GetView("EmbedView2") 

    Call dc.PutAllInFolder("EmbedFolder") 
    Call workspace.DialogBox("Embedded form", True, True, True, True, False, False, "Select Part No",,True,True) 

    'Call dc.RemoveAllFromFolder("EmbedFolder") 

End Sub 
+0

您的應用程序是否使用ReaderName或AuthorName字段? –

+0

@RichardSchwartz不,我不是。我只是從正常的領域獲得價值。謝謝你的問題。 – Arita

+0

我不問你從哪些領域獲得價值。我詢問整個應用程序中是否使用了ReaderName或AuthorName字段。我在問,因爲如果使用這些字段,這會隱藏你的一些文件,所以你的代碼將無法獲得它們。 –

回答

0

您是否試圖單獨處理每個鍵值?

Set view = db.GetView("EmbedView2") 
ForAll key in keys 
    Set dc = view.GetAllDocumentsByKey(key,False) 
    Call dc.PutAllInFolder("EmbedFolder") 
end ForAll 

[編輯]爲了解問題出在哪裏,檢查你的鍵是否真的返回數據。查看每個鍵的輸出。

Set view = db.GetView("EmbedView2") 
ForAll key in keys 
    Set dc = view.GetAllDocumentsByKey(key,False) 
    print "*** for " + key + " number or matching: " & dc.Count 
    Call dc.PutAllInFolder("EmbedFolder") 
end ForAll 
+0

我嘗試了上面的代碼,但仍然無法獲取該視圖中的所有文檔。結果仍然是我原來的代碼。謝謝你的建議。 – Arita

+0

看我的編輯,我懷疑你的鍵值有問題 –

+0

關於鍵值檢查的問題,我在我的代碼中使用了dc.count來檢查一些返回的文件,但那是不應該返回的文件中的。這是我的問題。謝謝你的建議 。 – Arita