Das Notes Forum

Domino 9 und frühere Versionen => ND6: Entwicklung => Thema gestartet von: Alexis am 15.12.05 - 14:25:05

Titel: Felder updaten über mehrere Antworthirarchien
Beitrag von: Alexis am 15.12.05 - 14:25:05
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
Titel: Re: Felder updaten über mehrere Antworthirarchien
Beitrag von: koehlerbv am 15.12.05 - 14:28:00
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
Titel: Re: Felder updaten über mehrere Antworthirarchien
Beitrag von: Axel am 15.12.05 - 15:06:13
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


Axel
Titel: Re: Felder updaten über mehrere Antworthirarchien
Beitrag von: Alexis am 16.12.05 - 09:41:04
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