clearString neatComponents 
Documentation

  

neatComponents is the hybrid-cloud database engine that powers clearString.

Previous pageTechniques & KB Articles Next page
Named Parameter Expansion for 'mailmerge' 

There are situations where you need to provide 'mailmerge' functionality, where a text document with embedded codes is combined with data from a separate source, so that it substitutes the codes with appropriate data.

This is useful for completing template documents.

Create the Template table

Create a Table, and include a Rich Text field.

In this each record represents a separate template document. (There may only be one record needed if there is just one template)

Edit the rich text field, entering the boilerplate text.

Where some content will needed to be inserted, enter a shorthand code.

This has the format:

{code}

ie a curly open-bracket, followed by some lowercase text, and a curly close-bracket.

The code should not contain any spaces or punctuation.

Advanced options:

Require a value:

If it is essential that a non-empty value is provided when the merge is performed, use two curly brackets, ie:

{{code}}

Specify a Root Parameter should be used:

Normally a Parent Parameter is used, but sometimes it is useful to use a Root Parameter value when the merge is performed. To do this, add a tilde before the code name.

{~code}

These options can be combined:

{{~code}}

You can include any number of these codes in the document. If the same substitution is needed in several places, use the same code for each of them.

When the Rich Text content is submitted, the system will convert the bracket codes (the 'shorthand') into embed tags. If you subsequently edit the rich text content, these can be edited by right-clicking on them and choosing Properties.

Create a Query, called say "Q: Template", which includes the rich text field (plus any other fields needed for criteria etc)

Create a Custom View on this query, and on the Records surface, embed the rich text field.

Create the data source with the code values

Create  a Table, with a set of fields, one for each different code used.

Create a Query, called say "Q: Data", based on this Table, which includes all the code fields (plus any other fields needed for criteria etc)

Note: This is the simplest scenario, but in many cases you may wish to create a Query based on multiple Tables, to allow values to be brought in from different sources.

Create a Custom View on this "Q: Data" Query, and embed on the Records surface of the Custom View the Custom View of the "Q: Template" Query. In the embed dialog:

  • On the Parent Parameters tab, complete the grid to select each of the fields that are providing the values for the codes, and populate the Parameter Name column with names that match the code names used in the template.
  • On the Records tab, in the Named Parameters section, set the Expansion dropdown to Expand.

Render the result to combine the data

Create a Page and embed the Custom View of the "Q: Data" Query.

Include criteria to restrict this to render a single template record, and to specify which data records should be used.

Now, when the Page is viewed, it should display the contents of the rich text field, with the {{code}} embeds substituted with the values from the data source.

Additional Resources

Techniques & KB Articles 
Copyright © 2025 Enstar LLC    All rights reserved Print this pageTranslate: