Domino 9 und frühere Versionen > Entwicklung
Alle Docs in eine Collection
HipSlu:
Hallo,
habe ein kleines Anfängerproblem und hoffe, daß Ihr mir ein wenig unter die Arme greiffen könnt....
Ich möchte per LotusScript alle Documente eines Views in eine Collection einlesen - nur weiß ich nicht, wie ich das anstellen kann - habe nur GetAllDocumentsByKey gefunden, und das ist ja natürlich nicht das richtige..... Das zweite Problem mit dem ich kämpfe ist folgendes: ich möchte dann mittels Print 2 Felder jedes Dokumentes ausgeben, bekomme aber leider einen typ mismatch.... anbei mal mein versuch:
Sub Click(Source As Button)
Dim nab As New NotesDatabase("","")
Dim books As Variant
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument
Dim i As Integer
Dim username As NotesName
Dim view As NotesView
Const DomainNABRepID$="xxxxxxxxxxxxxxxxxx"
Const NABServer$ = "xxxxx/xxxxx/xx"
Print "Opening NAB on: " & NABServer$ "
'NAB öffnen
If Not nab.OpenByReplicaID( NABServer$, DomainNABRepID$ ) Then
Msgbox "Failed trying to access address book, action aborted. "& ".", MB_ICONSTOP, "Public Address Book Access Failure"
End If
'Personen einlesen
Print "Looking up Users in address book"
Set view=nab.GetView("($Users)")
Set collection=view.GetAllDocumentsByKey("a",False)
If collection.count=0 Then
Msgbox "Nothing found", MB_ICONSTOP, "Person Document Lookup Failure"
Exit Sub
End If
Set doc=collection.GetFirstDocument
For i=1 To collection.Count
Print("Found: " & i)
' Print(doc.FirstName)
Set doc=collection.GetNextDocument(doc)
Next
End Sub
doliman:
Hi,
1. die view katagorisieren nach Maskenname und das als Key übergeben bei
Set collection=view.GetAllDocumentsByKey("Maskenname",False)
2. bei Print
Print(doc.FirstName(0))
Ich hoffe das funzt.
Axel:
Hi,
zu 1.
in R5 gibt es neuen Klassen (NotesViewEntry, NotesViewEntryCollection ), damit geht sehr elegant.
Beispiel aus der Designer-Hilfe
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim vc As NotesViewEntryCollection
Set db = session.CurrentDatabase
Set view = db.GetView("By Category")
Set vc = view.AllEntries
vc enthält alle Einträge der Ansicht.
zu 2.
Aufbauend zu 1. kannst du das für die Ausgabe so erweitern:
Dim entry As NotesViewEntry
Dim doc As NotesDocument
Set entry = vc.GetFirstEntry()
Set doc = entry.Document
While Not (doc Is Nothing)
Print doc.Feldname(0)
...
Set entry = vc.GetNextEntry(entry)
Wend
Axel
doliman:
Hi,
suppe das hab' ich doch glatt übersehen ;)
HipSlu:
Hallo,
vielen Dank für Eure rasche Hilfe - es funkt allerdings nicht so wirklich.... Ich bekomme bei
Set doc = entry.Document
den Fehler:
"Entry is no longer in View: ($Users)"
Sub Click(Source As Button)
Dim nab As New NotesDatabase("","")
Dim collection As NotesViewEntryCollection
Dim entry As NotesViewEntry
Dim doc As NotesDocument
Dim view As NotesView
Dim i As Integer
Const DomainNABRepID$="xxxx"
Const NABServer$ = "xxxx/xxx/xx"
Print "Opening NAB on: " & NABServer$
'NAB öffnen
If Not nab.OpenByReplicaID( NABServer$, DomainNABRepID$ ) Then
Msgbox "Failed trying to access address book, action aborted. "& ".", MB_ICONSTOP, "Public Address Book Access Failure"
End If
'Personen einlesen
Print "Looking up Users in address book"
Set view=nab.GetView("($Users)")
Set collection= view.AllEntries
If collection.count=0 Then
Msgbox "Nothing found", MB_ICONSTOP, "Person Document Lookup Failure"
Exit Sub
End If
Set entry=collection.GetFirstEntry()
Set doc = entry.Document
While Not (doc Is Nothing)
Print doc.FirstName(0)
Set entry = collection.GetNextEntry(entry)
Wend
End Sub
Navigation
[0] Themen-Index
[#] Nächste Seite
Zur normalen Ansicht wechseln