What is this?
The ability to insert a set of text elements into a template based on the choices made by a User.
When and where can this be used?
A text element can be re-used in multiple documents.
Whenever a User generates a new document which uses this text element, the latest version of the text element uploaded by the Admin will always be used.
A document is put together dynamically from a template and any number of text elements when a user creates it via Templafy.
A template can 'subscribe' to specific text elements, or the text elements can be inserted based on the choices made by the User.
Examples of documents where this can be used
- Sales quote - products and descriptions inserted based on Sales Agent choices.
- Employee contract - the main body text is 90% the same, and the remaining 10% is based on the employee.
- Proposal - based on which products and services are included in a proposal, the relevant legal disclaimers are inserted.
For creating complex documents where one or more text elements are inserted based on the choice of a User, Templafy can insert text elements into content controls.
In this article, we will use the example of different disclaimers for different countries. A User selects a country, and Templafy inserts one or more text elements based on that choice.
Basic knowledge of the following is required:
The set up for this example will contain 4 steps. Setting up the Text Elements, setting up the Data Source, setting up the User Form and setting up the Template.
Setting up the Text Elements
First, decide on the data you want to insert into the Template based on the user choice. In this case, it is legislation, disclaimers, laws, and guidelines based on different countries. We split these up into individual Word documents, saved and given a recognizable name. You should end up with something looking like this:
These documents are then uploaded as text elements to Templafy. Note that any folder structure is recognized, and you can upload the documents as a zip file.
For the purpose of this exercise, the 'asset id's' need to be extracted from the uploaded text elements. This is done by opening the text element in Templafy, and extracting the number visible in the URL. It will be between / and ?
Every text element will have a unique Asset ID, and we need to create a list of them. The best practice is to make a separate list, linking descriptions to the id's. This can also be achieved in the Data Source, as seen below.
Setting up the Data Source
In the Data Source, we need a column to select the variable (in this case, country) and the Asset id's of the text elements which relate to that country. Note that the description text only has the purpose of recognizing which text element the id belongs to. Different variables can have different amounts of texts.
Setting up the Form
Setting up the form is straightforward. A new form is created in the form editor. It can be attached to the templates to exploit the functionality described in this article.
- Give the form a recognizable name.
- Select the DropDown type, make it required if necessary.
- Select the Data Source created in the previous step.
- Select the column containing the variables, in this case 'country'.
Setting up the Template
It is possible to set up the template starting with an existing document that already has formatting, but for this example, the template is blank.
For inserting text elements, Content Controls are used. These will be where the eventual text is inserted, be it the header, footer, or body of the document. The expression binding used should look like this:
This tag inserts a text element based on an asset id. The asset id comes from a data source, and is based on the form attached to the document. Based on the choice of the user, it relates to a certain row of the Data Source. 'Text1' is the name of the column of the Data Source that the string relates to.
Bear in mind that Template Designer is case sensitive. All column labes (column names in the data sources) by default start with a CAPITAL letter, even though they might be displayed as lowercase.
It should be noted that Text Elements can only be inserted into Content Controls that are either Block or Cell level. Inline Content Control is not supported for insertion of Text Elements, simply because it is assumed that the Text Element will contain more than 1 line of text (read block of text).
The maximum amount of Content Controls used by any of the variables are inserted into the Template. On creation, when the text is inserted, the excess Content Controls will be deleted.
When the Template is configured, upload it to Templafy and attach the form we created earlier.
You now have a Template with Dynamic Text Elements!