Introduction: Debugging Templates

When test assembling templates, you may find that some scripting or automation in your template isn’t producing the result you expect. Perhaps you have created a computation script that is producing an answer you think is wrong. To help you troubleshoot situations like this, you can test your templates, resources, or scripts in Debug mode. You do this by inserting a DEBUG instruction in the template, resource, or script you think may be causing the unexpected result. Then, you test it using an answer file. When HotDocs processes the DEBUG instruction, it brings up the HotDocs Debugger so you can step through the script line by line, examining the components and any answers that may be causing the problem. The Debugger allows you to observe how a script is being processed or how a document is being assembled.

While debugging your templates, resources, or scripts, there are several options you can use to help you diagnose the problem. For example, you can add variables to a “watch list,” which allows you to track how answers to certain variables change depending on how other questions are answered in the interview.

The Debugger also displays the processing stack which shows, starting from the bottom, the templates and components HotDocs is processing at the field or line you are currently examining. For example, if you are debugging a computation script in an inserted template, the processing stack would include the name of the parent template, the name of the inserted template, and the name of the Computation variable. Viewing the stack can help you understand what part of the interview you’re viewing as well as provide the path for how you got to it.

You can use the information you gather from debugging to correct problems with automation.