Domino 9 und frühere Versionen > ND6: Entwicklung
Felder updaten über mehrere Antworthirarchien
(1/1)
Alexis:
Hallo Forum,
hat jemand einen Ansatz, wie man den geänderten Inhalt von Felder des Hauptdokumentes über mehrere Ebenen von Antwortdokumenten hinweg abgleichen kann?
Über eine Ebene ist das ja noch machbar: Collection + Stamp, aber wie geht das über mehrere Ebenen?
Alexis
koehlerbv:
Ein typisches Beispiel für Rekursion: Collection bilden, Collection durchgehen und jedes Doc auf Children testen, wenn ja, wiederum Collection bilden usw., bis man nix mehr findet.
HTH,
Bernhard
Axel:
Das Beispiel habe ich vor einiger Zeit mal aus dem Web gefischt.
--- Code: ---Sub Querysave(Source As Notesuidocument, Continue As Variant)
Set curDoc = Source.Document
'..code to create the empItems record array has been deleted from here
Call UpdateAllResponseDocs (curDoc, empItems() )
End Sub
Sub UpdateAllResponseDocs( docToCheck As NotesDocument, empItems() As employeeItems)
On Error Resume Next
Dim responseDocuments As NotesDocumentCollection
Dim responseDoc As NotesDocument
Dim m As Integer
Print "Updating Response Docs for " & docToCheck.Form(0)
Set responseDocuments = docToCheck.Responses '...get all immediate responses of this document
If responseDocuments.Count > 0 Then
For m = 1 To responseDocuments.Count
Set responseDoc = responseDocuments.GetNthDocument(m)
'..update your items here
Call responseDoc.Save (True, True)
'...this sub gets recursively called until all response docs are updated
Call UpdateAllResponseDocs( responseDoc, empItems )
Next
End If
End Sub
--- Ende Code ---
Axel
Alexis:
Hallo Axel, hallo Forum,
mit ein paar Änderungen funktioniert die rekursive "Vererbung" von Feldinhalten in alle Response-Ebenen hinunter. Vielen Dank für den Tipp Axel.
Sub Querysave(Source As Notesuidocument, Continue As Variant)
Dim curDoc As NotesDocument
Dim empItems(… To …) As String
Set curDoc = Source.Document
'... code to create the empItems record array
empItems(1) = curDoc.FieldName(0)
.....
Call UpdateAllResponseDocs (curDoc, empItems() )
End Sub
Sub UpdateAllResponseDocs( docToCheck As NotesDocument, empItems() As String)
On Error Resume Next
Dim responseDocuments As NotesDocumentCollection
Dim responseDoc As NotesDocument
Dim m As Integer
'...get all immediate responses of this document
Set responseDocuments = docToCheck.Responses
If responseDocuments.Count > 0 Then
For m = 1 To responseDocuments.Count
Set responseDoc = responseDocuments.GetNthDocument(m)
'..update your items here
Set Item = responseDoc.ReplaceItemValue( "FieldName", empItems(1) )
…………..
Call responseDoc.Save (True, True)
'...this sub gets recursively called until all response docs are updated
Call UpdateAllResponseDocs( responseDoc, empItems )
Next
End If
Alexis
Navigation
[0] Themen-Index
Zur normalen Ansicht wechseln