Trouble with logic around recurring document collections

Posted on 2004-11-01
Medium Priority
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
  • 2
LVL 19

Expert Comment

ID: 12461793
Hey buddy,


Author Comment

ID: 12461818

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

Mind is messed up with other things...

Do you have any idea how to overcome this problem ?


Accepted Solution

Alexey_Zubkov earned 2000 total points
ID: 12462686
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

ID: 12464333
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?

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
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…
The video will let you know the exact process to import OST/PST files to the cloud based Office 365 mailboxes. Using Kernel Import PST to Office 365 tool, one can quickly import numerous OST/PST files to Office 365. Besides this, the tool also comes…
From store locators to asset tracking and route optimization, learn how leading companies are using Google Maps APIs throughout the customer journey to increase checkout conversions, boost user engagement, and optimize order fulfillment. Powered …
Suggested Courses

588 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