7.5 Creating a Document Template with Table Custom Fields
This lesson will show you how to set up a document template to include a custom field table. Before trying this you should know how to create a simple document, which you can learn here.
Custom field tables
In AgileCase it is possible to set up tables of custom fields within a case, to learn how to do this, follow this lesson.
Like any other field, these tables can be exported to a document using a template, however the process is a little more complicated than with standard fields.
Locate the table in the Merge Field Helper
On the merge field helper for the case, find the field table you want to add to the template. it will be prefixed with the element "<Case.Custom.Table. (name of the table)>". These fields are the ones you will use to create your table in the template.
Create a table in word and enter your mergefields
In order to ensure the table is properly formatted in the resulting document, create a table in word and populate this with your mergefields.
When creating a table you must create two additional mergefields, on at the start of the table and one at the end.
At the start you should create a mergefield {MERGEFIELD TableStart:(name of the table)} and at the end you should make one {MERGEFIELD TableEnd:(name of the table)}. This will signal to the system that you are creating a table and will cause it to populate a row of information for each entry.
The screenshot above shows mergefields that have been copied out of AgileCase. These include the entities "Case.Custom.Table". These should be deleted when they have been copied across or, and should not be included if you are writing your own mergefields.
To create these mergefields, first press Alt+F9, this will activate Mail Merge mode. Then press Ctrl+F9 to insert a Mail Merge field, you will know this is successful as a set of squiggly brackets { } will appear.
Mail merge can create many different types of field so to set this as a mergefield ensure that you first type MERGEFIELD in capitals before entering the details of the field in the exact format above.
Please note that mergefields are case sensitive so ensure that the element in the document is in the correct format. Another important thing to note is that mergefields must be updated after you edit them. To do this, right click on the mergefield and select "Update Field" to save the changes you have made.
These fields should be placed in the same column as your first field, before the fields, and in the same column as your last field, after the field.
The other mergefields in the table should be copied in to the appropriate column without any modification. If you want to use table headings, create a two row table and enter the headings in the top row above the apporpriate mergefield.
Create your document as normal
Create a document and select your template containing the custom field table.
Your table will be now be correctly formatted in the document
Your table will appear as you set it up in the template, with a row for each entry you have made in the field table in AgileCase.