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

Advanced Text Merge Using the NVelocity Component

  • Print
  • Dark

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.


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.

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


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

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.

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



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 .


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 .



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.

To iterate through our collection of folders, we will map the output of the Get All component to the Collection input.


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 .

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.

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.


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 .


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.

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.

When we open the downloaded CSV file, we will see that it contains rows for every folder in our system.

Was this article helpful?