Manage Learn to apply best practices and optimize your operations.

Creating An Artifical Hierarchy

This helps prevent unrecoverable orphins and allows Reponse Docs, as well as
Response to Response Docs to be seperated from Main docs in various view, if it
is needed.

This involves : 3 forms, 2 hidden views, and least one visiable view, some
formula language, andquite a bit of LotusScript.
Parent Form or Main Form:
For the properties: Alias: Main, Form type is Document, all the properties can
be set as desired.
For fields on the form: 3 hidden text fields are needed.
The needed fields are as follows
Field: ID, is computed, and its value is: @Text(@DocumentUniqueID)
Field: DocType, is computed when composed, and its value is: "Main"
Field: ResponsePresent, is editable, and its default value is: "No"


The ID field contains the document's unqiue id, the DocType field, for this
form is always "Main", and the ResponsePresent field, tracks whether or not
this document has Response documents, or ResponseToResponse documents.


The Querysave event will be as follows: Note: The(UpdateParentInfo) view will
be created in just a short while.
Sub Querysave(Source As Notesuidocument, Continue As Variant)
Dim Session As New NotesSession
Dim Workspace As New NotesUIWorkspace
Dim DB As NotesDatabase
Dim ParentIDView As NotesView
Dim AllChildrenDocs As NotesDocumentCollection
Dim NumOfChildren As Long
Dim ParentDoc As NotesDocument
Dim ParentUIDoc As NotesUIDocument
Dim ParentUNID As String
Dim ChildDoc As NotesDocument
Dim NeedToSaveChild As Integer
Dim LastChildDoc As NotesDocument
Dim IsNewDocFlag As Integer
Dim NewValue As String
Dim ParentItem As NotesItem
Dim ChildItem As NotesItem
Dim ResponseAvailable As String


NeedToSaveChild = False
Set DB = Session.CurrentDatabase
Set ParentIDView = DB.GetView("(UpdateParentInfo)")
Set ParentUIDoc = Workspace.CurrentDocument
Set ParentDoc = ParentUIDoc.Document
ParentUNID = ParentDoc.UniversalID
NewValue = ""

' If this is a new document then there are no children documents no
need to proceed with checking the values in the children documents.
IsNewDocFlag = Source.IsNewDoc
If IsNewDocFlag = False Then
Set DB = Session.CurrentDatabase
Set ParentInfoView = DB.GetView("(UpdateParentInfo)")
Set ParentUIDoc = Workspace.CurrentDocument
Set ParentDoc = ParentUIDoc.Document
ParentUNID = ParentDoc.UniversalID
ResponseAvailable = Source.FieldGetText("ResponsePresent")
On Error Resume Next
Set AllChildrenDocs = ParentIDView.GetAllDocumentsByKey(ParentUNID,
True)
NumOfChildren = AllChildrenDocs.Count
'Check to see if there are any children
If NumOfChildren = 0 Then
' If there are no children then there is nothing that needs
to be updated in the response, or the response to response documents.
If ResponseAvailable = "Yes" Then
Call Source.FieldSetText("ResponsePresent", "No")
End If
Goto NoChildren
End If
' Set the first child doc
Set ChildDoc = AllChildrenDocs.GetFirstDocument
' set the last child doc
Set LastChildDoc = AllChildrenDocs.GetLastDocument
For x = 1 To NumOfChildren
Set ParentItem = ParentDoc.GetFirstItem("Field1")
Set ChildItem = ChildDoc.GetFirstItem("Field1")
' compare parent subject value to child subject value, if
different then set the child doc subject to be the same as the parent
If ParentItem.Values(0) <> ChildItem.Values(0) Then
NewValue = ParentUIDoc.FieldGetText("Field1")
Call ChildDoc.ReplaceItemValue("Field1", NewValue)
NeedToSaveChild = True
End If
Set ParentItem = ParentDoc.GetFirstItem("Field2")
Set ChildItem = ChildDoc.GetFirstItem("Field2")
' compare the parent categories value to the child
categories value, if different then set the child doc categories to be the same
as the parent
If ParentItem.Values(0) <> ChildItem.Values(0) Then
NewValue = ParentUIDoc.FieldGetText("Field2")
Call ChildDoc

Dig Deeper on Lotus Notes Domino Administration Tools

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close