<< Click to Display Table of Contents >>

How to create a document template with dynamic fields

A dynamic field is a field that can change depending on the information that you provide, so for example if you are using a database such as ACT! a dynamic field can be added that differs for each record.  Adding dynamic fields to your Zetadocs PDF templates allows them to be personalized for use with large scale document production.


Embedded commands within the template

You can add dynamic fields to the email properties page of your document template:




These dynamic fields must be set up in the following format:


%%[Field: «fieldname», «defaultvalue»]


This command can be used within the delivery information in the recipients, subject and body text of the email.



Fieldname is any descriptive word for your field, but with no spaces e.g.  firstname

Defaultvalue is the value you wish to be added if this field is not present in your data source.


The fields can be declared as %%[fieldname, defaultvalue] or simply %%[fieldname] e.g. %%[firstname, customer].



%%[Field: firstname, customer]


Having set up your document template, these fields need to added to your mail merge document and merged with your data source.




%%[Field: firstname, Harry]


If the value of the field is not found in document, then the embedded command will use the default value and if the default value has not been specified then the text will be left as it was defined. So in the above example if the document has defined a dynamic field as firstname then it will be replaced with the value Harry, if not then it will replace it (if it has been declared) with customer.


Dynamic fields can be combined with the other embedded commands. You can use these fields to put merge values in any set embedded command.




%%[Field, name, Harry]

%%[Field, company, Widgets Inc.]

%%[OutputFilename: %%[company] - %%[name] ]


The output filename of the document that includes the above embedded commands will be “Widgets Inc. – Harry”. As before, you can also add a default value.


For example:


%%[OutputFilename: %%[company] - %%[firstname, Customer]]


So the output filename of the document this time will be “Widget Inc. - Customer”, since the dynamic field firstname was not defined in the document.


Note that only one level of nested dynamic fields is supported. so the following command would be invalid:


%%[OutputFilename: %%[company, %%[name]] - %%[name] ]


Related Topics

Sample embedded command documents