Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

609 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