The HotDocs instruction “FILTER” is one that I use in almost every system that I’ve designed. Its purpose is exactly what it sounds like – to filter (a repeat), based upon a certain criteria, so that the data output from the repeat is reduced – only the repeats that match the filter come out. Like most instructions, it is best explained by example.
Lets say we have a repeating dialog named “Party RPT” that collects information regarding, well, parties in our fictitious matter. A party can be a corporation or individual (PARTY Entity Type MC), but never both. Throughout our system, we are constantly required to insert a sequence of all party names, as well as a sequence of all corporation names. While we COULD use REPEAT instructions in our templates, this will not work in repeating templates, nor repeating sections. So lets use the filter command to meet our requirements AND simplify code (its much easier to pre-calculate such lists instead of coding them in every template!).
Party RPT (dialog)
PARTY Name TE (name of party)
PARTY Entity Type MC (type of entity - individual or corporate).GEN Parties All Names TE (list of all names of all parties)
GEN Parties Corp Names TE (list of all corporations only)
So lets do our “list of all parties” first – this would go in a computation…
""
SET GEN Parties All Names TE TO UNANSWERED
REPEAT Party RPT
FORMAT "a, b and c"
RESULT + PARTY Name TE
END REPEAT
SET GEN Parties All Names TE TO RESULT
That’s it – all done. Very simple, and now GEN Parties All Names TE contains something like “Seth Rowland, Basha Systems LLC, Ian Burrows, Routine Automation Pty Ltd and John Doe”
Now, lets use our FILTER instruction to slim that list down to only the companies. Here is our filter computation, named “fil Party Companies CO”
PARTY Entity Type MC = “Corporation”
That’s it – a straight forward test: is the party entity type a corporation? yes/no. So lets use this, again in a computation…
""
SET GEN Parties Corp Names TE TO UNANSWERED
REPEAT Party RPT
FILTER fil Party Companies CO
FORMAT "a, b and c"
RESULT + PARTY Name TE
END REPEAT
SET GEN Parties Corp Names TE TO RESULTGEN Parties Corp Names TE now has a value of "Basha Systems LLC and Routine Automation Pty Ltd".
Filters are absolutely fantastic, as they allow you to eliminate a lot of repetitive code and variables. Take a litigation system for example, with Plaintiffs, Defendants, Third Parties, Plaintiffs by Counterclaim, Defendants by Counterclaim. You COULD have a separate repeat for each of these parties. Alternatively, you could have a repeat for Plaintiffs, with a checkbox to indicate that they are also optionally a defendant by counterclaim – then use filters on this variable. Taking it one step further, you could simply have a dialog Parties that contains ALL parties in the matter, then use multiple-choice, multiple select variables to specify all the roles that a given party may have. Another example is real estate documents – a given party may be a borrower, but optionally a mortgagee. If it is an investment property, they may also be a lessor/landlord. Occassionally, they may ALSO be a caveatee.
Filters allow you to collect information once centrally and then filter it in various ways to produce exact results.