Jump to content

Printing a tree structure report


This topic is 2891 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I have 5 tables, all related hierarchically (parent id).


What I'd like to accomplish is to make a report of the whole tree. Something like:


1 (T1)

  1 (T2)

    1 (T3)

      1 (T4)

        1 (T5)

        2 (T5)

        3 (T5)

  2 (T2)

2 (T1)



I've tried to make subsummaries of each ID, changing the sort order, using the highest tabla as layout, the lowest, and I came to know... I can't do it. :hmm:


Any advise? :grad:


I attach a sample file with my trail and error.


Link to comment
Share on other sites

I think what I wanted to have done is more complicated than what you want, but I'll share what I did.


I have a single table (related to other tables, but that's not really relevant) in which priority relationships are defined.  Each record this table has a "higher node," a "lower node," and how the lower is related to the higher.  The tree is a true tree -- each lower node can have just a single higher node but a given node can be a higher node to more than one lower nodes.


What I wanted to do was, starting at any given node in the tree, display all the records in that tree, and also generate an image of the tree itself.  The basic workflow is that it firsts finds the root node of the tree (the node that is not lower to any other node), and then recursively looks for all the children of each node until it runs out.


I've attached three scripts.  The meat scripts are "Find family matters," which finds the root node, and "Find immediately lower family matters" starting at the root node, where this latter script recursively calls itself.  Each time the "lower family matters" script is called, it adds a name of the current record to a value list called $$matterlist.  The script "Display family matters," which is called at first but then immediately calls "Find family matters" basically, assembles the list for display in the report. 


To generate the image, the "lower family matters" appends lines of text to a text file "tree.txt" that is then passed to a program called GraphViz (opensource, available at graphviz.org) via a "dot" command line to generate the image, and a use a program called Xee to display the created image (we only use Xee for displaying things generated in FileMaker -- it's essentially equivalent to Mac's Preview app, but we use that for a lot of things, so I didn't want any existing Preview docs being mucked up).


I do rely on a couple of plugins.  First, Troi Dialog to tell the user what's going on.  Second, Troi file to actually create the text file.  Both of these are available at troi.com.


I've also attached a screenshot of the list of a typical tree, the visual image of the tree, and the text file that my scripts create to pass to GraphViz to generate the tree.

Display file matters.pdf

Find family matters.pdf

Find immediately lower family matters.pdf




Link to comment
Share on other sites

This topic is 2891 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.