Das Notes Forum

Domino 9 und frühere Versionen => Entwicklung => Thema gestartet von: HipSlu am 31.07.02 - 11:21:15

Titel: Alle Docs in eine Collection
Beitrag von: HipSlu am 31.07.02 - 11:21:15
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

Titel: Re: Alle Docs in eine Collection
Beitrag von: doliman am 31.07.02 - 11:33:10
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.

Titel: Re: Alle Docs in eine Collection
Beitrag von: Axel am 31.07.02 - 12:16:40
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
Titel: Re: Alle Docs in eine Collection
Beitrag von: doliman am 31.07.02 - 12:24:49
Hi,

suppe das hab' ich doch glatt übersehen ;)
Titel: Re: Alle Docs in eine Collection
Beitrag von: HipSlu am 31.07.02 - 12:47:52
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
Titel: Re: Alle Docs in eine Collection
Beitrag von: Axel am 31.07.02 - 13:21:22
Hi,

ich habs mal getestet und hatte den gleichen Fehler. In der While-Wend Schleife hat sich ein Fehler eingeschlichen (bin heute wahrscheinlich auf beiden Ohren blind  :-/).

Ändere die Schleife wie folgt ab:

Set entry=collection.GetFirstEntry()
     
While Not (entry Is Nothing)
 Set doc = entry.Document  
 Print doc.FirstName(0)    
 Set entry = collection.GetNextEntry(entry)    
Wend

Allerdings auch mit dieser Änderung kam der gleiche Fehler. Erst nachdem ich auf eine andere Ansicht verwiesen habe, hat's funktioniert.

Set view=nab.GetView("($People)")


Axel
 
Titel: Re: Alle Docs in eine Collection
Beitrag von: HipSlu am 31.07.02 - 14:50:17
Hallo,

vielen Dank erstmal - jetzt funktioniert es..... ich versuche erst gar nicht zu verstehen, warum es mit dem anderen View nicht funktioniert  ;D

Titel: Re: Alle Docs in eine Collection
Beitrag von: Axel am 31.07.02 - 15:17:18
Hi,

das habe ich auch aufgegeben.  :-/

Getreu dem Motto:   ;D ;D

"Alles was du nicht verstehst, musst du als gegeben hinnehmen"

(ist von meinen ehemaligen Ausbilder)

Axel