Advanced Text Merge Using the NVelocity Component
  • Updated on 10 Jul 2019
  • 3 minutes to read
  • Print
  • Dark
    Light

Advanced Text Merge Using the NVelocity Component

  • Print
  • Dark
    Light

NVelocity is an open source java template engineering framework. The Custom Merge [NVelocity] component allows variables to be merged with text in a defined template. These templates can be used to generate CSV data, HTML, XML or other forms of structured text.
A use case for this functionality could be to create a standardized letter or to replace text within existing documents that need updating.

Example

In our example flow, the Custom Merge [NVelocity] component will generate a CSV file containing a list of folders. We will then display a form with which the user will be able to download the CSV file that was just created. This example assumes that this form "Download Folders CSV Form" has already been designed.
2018-01-25_143725.png

We will begin in a Designer Folder by clicking the Create Flow button.

2019-07-08_1514.png

In the resulting New Flow pop-up, we will name our flow "Get CSV of Folders Flow" and click OK .
2019-07-08_1515.png

We will first create the String which will contain our CSV file data. We will find the Create or Copy Data component in the Flow Designer's start-up window, under the category All Steps [Catalog] > Data . Click Add to add it to the workspace.
2019-07-08_1516.png

In the Data Definitions section, we will click the Add button and define an output called "CSVRows" with a type of String.
2019-07-08_1517.png

2019-07-08_1519.png

2019-07-08_1518.png

Next, we will retrieve all of the folders in our system. We will find the relevant Get All component in the Toolbox tab, under the category Integration > Internal Services > FolderService .
2019-07-08_1520.png

2019-07-08_1521.png

Next, we will iterate through the folders we've retrieved. We will find the ForEach Step component in the Toolbox tab, under the category Flow Management .

2019-07-08_1522.png

2019-07-08_1523.png

While the For Each step is selected, in the Properties tab, under the Data section, we will open the Type selector and define a collection type of Folder.
2019-07-08_1524.png

To iterate through our collection of folders, we will map the output of the Get All component to the Collection input.
2019-07-08_1525.png

2019-07-08_1526.png

For each folder retrieved, we would like to merge certain form properties into a CSV row and add it to the rows already defined. We will find the Custom Merge [NVelocity] component in the Toolbox tab, under the category All Steps [Catalog] > Data > Text .
2019-07-08_1527.png

Our template will begin with the CSV rows that have already been defined. On the second line, it will contain each folder's entity name, date of creation and short type name all comma-delimited. Once we've defined our template, the inputs necessary for populating these dynamic variables will be automatically generated.
2019-07-08_1529.png

In the Mapping Editor, we will map, from the Item drop-down, CSVRows to CSVRows . We also map the CreatedOnDate , EntityName and FolderTypeName properties of each Folder item to the appropriate input. We will also rename the output to "CSVRows", so that each iteration aggregates the new row with the old ones.
2019-07-08_1530.png

2019-07-08_1532.png

Next, we would like to display the form with which we'll download our CSV file. We'll find Download Folders CSV Form in the Toolbox tab, under the category Forms [Interaction] > [Root Folder] > Designer Entities .

2019-07-08_1539.png

This completes our flow, so we will save it and close the Flow Designer.
Back in our Designer Folder, we will select Get CSV of Folders Flow and select Run Flow from the actions menu.
2019-07-08_1540.png

In the resulting pop-up, we will be shown the Download CSV of Folders form. We will click the Download File button to download the CSV file that was created by our flow.
2019-07-08_1541.png

When we open the downloaded CSV file, we will see that it contains rows for every folder in our system.
2016-12-09_164957.png

Was this article helpful?