Trouble with logic around recurring document collections

Posted on 2004-11-01
Last Modified: 2013-12-18
Hi all

I am trying to build an org chart using document collections. currently , I get the CEO of the company & the build a document collection of all the people who are under Him/Her . Then I call the function again to complie the collection under that person & so on  & so on....

My problem is that I can build the structure  fine for the first person under the CEO but I cannot go back up the strucure to get to the next person ...

                       Person 1
                           Person 1.1
                           Person 1.2
                             Person 1.2.1
                           Person 1.3
                      Person 2
                      Person 3
in my sub routine , I can get the following structure :

                               Person 1
                                    Person 1.1
then I am stuck cos I have lost my previous collections .... any ideas

Here is the code that I currently have :

Sub GetEmployees(ID As String)
      Set EmployeeCollection = View.GetAllDocumentsByKey(ID)
      If EmployeeCollection.Count = 0 Then
            Print  "No Underlying Employees" + " <br>"
            CurrentTab = currentTab - 5
            Set EmployeeDoc = employeeCollection.GetFirstDocument
            While Not EmployeeDoc Is Nothing
                  CurrentTab = CurrentTab + 5
                  Print EmployeeDoc.FirstName(0) + " " + employeeDoc.LastName(0) + " <br>"
                  Call GetEmployees(EmployeeDoc.PersonID(0))
                  Set employeeDoc = EmployeeCollection.GetNextDocument(EmployeeDoc)
      End If
End Sub  
Question by:PParuman
    LVL 19

    Expert Comment

    Hey buddy,


    Author Comment


    ooh Thanks .... sorry , wrong terminology :)

    Mind is messed up with other things...

    Do you have any idea how to overcome this problem ?

    LVL 1

    Accepted Solution

    Define EmployeeCollection as local variable in this sub. Your previos collections will not lost after returning to previos levels and the same level of recursion.

    WBR, Alex
    LVL 19

    Expert Comment

    THere is a top level document. It is a Main document.

    And there are some level 2 documents. They are responses to top level document. They are response documents.

    And there are some level 3 documents. They are responses to level 2 document. They are response to response documents.

    And so on...

    The key lies in the fact that, you can easily write a routine that recursively drills-down the child document collection given its Unique Note ID. The routine will not only list the current level document but also recursively go down traversing down to the lowest level document in the hierarchy. They prototype of such a routine could be:

    Sub ListChildren (strParentDocID as string)

    Are you comfortable with the concept?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Suggested Solutions

    I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
    Article by: Rob
    Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
    In this Experts Exchange video Micro Tutorial, I'm going to show how small business owners who use Google Apps can save money by setting up what is called a catch-all email address in their Gmail accounts. By using the catch-all feature, small busin…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…

    884 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now