Domino 9 und frühere Versionen > ND6: Entwicklung

Daten aus Collection in ein Richtext schreiben

<< < (3/3)

Greenthumb:
Danke für so schnelle Antwort! Ich habe ein Richtext-Feld (ich will an das Feld letzten 3 Einträge aus Collection anhängen=> wenn ich mich nicht irre ist das in einem Textfeld nicht möglich). Hier mein Code:

Sub Initialize
   Dim session As New NotesSession
   Dim db As NotesDatabase
   Dim ws As New NotesUIWorkspace
   Dim collection As NotesDocumentCollection
   
   Set db = session.CurrentDatabase
   Set collection = db.UnprocessedDocuments
   
   Dim coldoc As NotesDocument
   Set coldoc = collection.GetFirstDocument
   
' Daten lesen aus der Sales-Maske...
   coldocid = coldoc.UniversalID
   firma = coldoc.GetItemValue("firma")(0)
   salesnum = coldoc.GetItemValue("salesnum")(0)
   projnum = coldoc.GetItemValue("projnum")(0)
   status = coldoc.GetItemValue("status")(0)
   ansprpart1 = coldoc.GetItemValue("ansprpart")(0)
   ....
'Die ausgelesenen Daten in Maske SchnellInfo(2)-sdoc schreiben....   
   Dim doc As NotesDocument
   Set doc= db.CreateDocument
   doc.Form = "SchnellInfo(2)-sdoc"
   doc.salesdocid= coldocid
   doc.firma = firma
   doc.salesnum = salesnum
   doc.projnum = projnum
   doc.status = status
   ...
   doc.kontakt1 = ""
                ...
   
   Dim collection1 As NotesDocumentCollection
   SSTR = "FORM = ""ToDo"" & firma = """ + firma + """ & salesnum = """ + salesnum + """"
   Set collection1 = db.Search(SSTR, Nothing, 0)
   
   For I=1 To collection1.Count
      
      Dim doc1 As NotesDocument
      Set doc1 = collection1.GetNthDocument(I)
      ansprpart = doc1.GetItemValue ("ansprpart")(0)
      datum = doc1.GetItemValue ("ddatum")(0)
      kontart = doc1.GetItemValue ("kontart")(0)
      thema = doc1.GetItemValue ("ToDo")(0)
      
      Dim item As NotesItem
      Set item = doc.GetFirstItem("kontakt1")
      Call item.AppendToTextList (thema + Chr(10))
                                ....
      
   Next
   
'Document anzeigen   
   Call ws.EditDocument (False , doc, False)

End Sub

Wie oben beschrieben:
1. AppendToTextList (thema +Chr(10)) hängt neuen Eintrag am Ende der nächsten Zeile
2. Collection1 liefert jetzt alle Einträge, ich möchte aber die letzten 3 auslesen und anhängen.  :-[

Danke!

Greenthumb:
Hallo Glombi!
Ich habe die Lösung für das erste Problem (Anhängen der EInträge am Ende der nächsten Zeile).
Für RT-Felder sollte die Zeile so aussehen: Call item.AppendToTextList (Chr(13) + thema(0))

Jetzt werden die EInträge richtig angehängt

Kennst Du welche Lösung für mein zweites Problem? Schlage mir bitte was vor.
Danke!

koehlerbv:
Wie wäre es mit
For I=collection1.Count - 2 To collection1.Count

Das ist doch dann die Schleife über die letzten drei Einträge.

HTH,
Bernhard

Glombi:
Um nur die letzten 3 Dokumente der Collection zu bekommen, kannst Du folgendes machen:

dim lbounb_i as integer
select case collection1.Count
case > 4: lbounb_i = collection1.Count -3
case else: lbounb_i = 1
End select

For I = lbounb_i To collection1.Count
     
      Dim doc1 As NotesDocument
      Set doc1 = collection1.GetNthDocument(I)
      ansprpart = doc1.GetItemValue ("ansprpart")(0)
      datum = doc1.GetItemValue ("ddatum")(0)
      kontart = doc1.GetItemValue ("kontart")(0)
      thema = doc1.GetItemValue ("ToDo")(0)
     
      Dim item As NotesItem
      Set item = doc.GetFirstItem("kontakt1")
      Call item.AppendToTextList (thema + Chr(10))
                                ....
     
   Next


Andreas

Greenthumb:
Vielen Dank!
Beide von Euch gezeigten Lösungen funktionieren!  :D
Somit ist das Thema abgeschlossen
Danke für Eure Hilfe!

Navigation

[0] Themen-Index

[*] Vorherige Sete

Zur normalen Ansicht wechseln