CIC Solutions Forums
Certified Independent Consultant Solutions Forums for
LexisNexis® Practice Management Products
Time Matters - PCLaw - Billing Matters - Browser Edition - HotDocs

Database connection - nested repeats?

rated by 0 users
This post has 2 Replies | 0 Followers

Top 500 Contributor
Posts 2
pclsa Posted: Tue, Jan 16 2007 12:41 PM
According to the HotDocs Template Development Guide "Nested repeats cannot be used if you are retrieving answers from a database using the HotDocs database connection".

Given that, what is the most sensible work around to set up a template that draws say the name and info of a department, then name and info for each employee in the department where that info then on to next department and so forth from an Access database.

David Garde
Legem Pty. Ltd.
Top 500 Contributor
Posts 0

The easiest way may be to create a query in the database that returns employee and department information and hook one database component up to the query rather than the db tables.  This creates, in effect, a flat file database where each employee's department information is listed in record for the employee.  You'll then need to script your HotDocs template to sort on the department and only include the department information where it changes (logic is basically:  is the first repeat or is the department name different from the previous repeat, if so, include department info).

Another approach is to create two db components, one for the department table, and one for the employee table.  Then use scripting in the HotDocs template to map the employee variables to the nested repeat.  You need to have two sets of employee vars--one set that you connect to the db, which is a simple level one repeat.  The other set will be nested in the department repeat.  Your scripting needs to SET the values in the nested repeat from the answers in the db connected employee repeat.

Neither approach is simple to implement, but first is probably simpler, depending on exactly how you need to use the answers in the template.


Bart Earle, CIC HotDocs Capstone Practice Systems 231 Woburn St. Lexington, MA 02420 781-652-8419 Skype: bvearle HotDocs development and training
Top 500 Contributor
Posts 2
pclsa replied on Thu, Feb 1 2007 9:34 AM
This is great advice Bart.  I took the simpler approach of a flat file database and it worked.  Programmatically though I am not so keen that I will have to run a work around with a flat file then filter out the repeating results from the "one" relationship to do this.  That's not neat.

Before getting the benefit of your advice I tried the double db components method using code at

The code supplied there by Benjamin Reich, is

//  Computation to take detail records retrieved through the DB
// connection, and properly relate the detail records to the
// appropriate master records.

// This is necessary, because HotDocs does not associate master
// and detail records properly. The issue is that HotDocs DOES NOT
// use two or more levels of reference values when pulling info
// from the DB connection into a nested dialog (contrary to
// the instructions in the HotDocs manual)


// Pull the master records from the database.
// The variables linked to the database are also
// contained in a dialog named "Master-dlg"
ASK Master-db

// Set the master record counter to zero
SET MasterCounter-n TO 0

REPEAT Master-dlg

// Increment the master record counter
SET MasterCounter-n TO MasterCounter-n + 1

// Set the filter to pull the appropriate detail records
// for this master record
SET ThisMasterID-n TO MasterID-n

// Pull the appropriate detail records from the database.
// The variables linked to the database are also
// contained in a dialog named "Detailed-tmp-dlg", which is
// nested on "Master-dlg"
ASK Detail-db

// Check how many detail records were retrieved.
// If there are any, we must copy the detail records
// to the correct location(s).
SET DetailCount-n TO COUNT( Detail-tmp-dlg )
IF DetailCount-n > 0

// Set a value in the target dialog "Detail-dlg" in the record
// equal to the total number of detail records which were
// retrieved for this master record
SET DetailText-t [ MasterCounter-n, DetailCount-n ] TO "x"

// Repeat the target dialog "Detail-dlg", which is also
// nested on "Master-dlg"
REPEAT Detail-dlg

// Set each value in the target nested dialog from the value
// in the source nested dialog
SET DetailDate-d TO DetailDate-tmp-d [ COUNTER ]
SET DetailText-t TO DetailText-tmp-t [ COUNTER ]
[One line for each variable taken from the source nested dialog to
the target nested dialog



I nearly got it working but I just couldn't figure the x in

SET DetailText-t [ MasterCounter-n, DetailCount-n ] TO "x"

It isn't explained in the further explanation set out at   which to my mind proves your point that this kind of method is harder to implement.

Regards, David Garde
Legem Pty. Ltd.
Sydney Australia

Page 1 of 1 (3 items) | RSS