Text Merge Extensions

Last Updated: 03/28/2018 Introduced in Version: 2.0

Decisions includes a number of built-in text merge fields like “Capitalize,” “Lower,” and “Insert Current Date.” These merge fields can be used to dynamically manipulate strings or insert data from other sources into a Text Merge.

Text merge extensions allow you to write custom text merge logic to accomplish any type of merge you would like. This example will show how to create a merge that returns the length of a string.
 
The IDE used in this demonstration is Visual Studio 2017.
 
To begin, download the Decisions SDK from Manage NuGet Packages.
 
Add the following using statements

Have your class inherit from and implement  AbstractStringFieldExtension.
 
When you implement this class you will see that it includes two override methods:  string GetMergeText and string Name.
 
The string returned by GetMergeText will be the string displayed at run time of your Text Merge. The string returned by Name will be the name of the merge displayed at design time.
 
Below is an example implementation of string Name which will return the name of Get String Length.
This name of Get String Length will show in the designer as shown below.
 
 getstringlength
 
Below is an example implementation of the string GetMergeText method which will return the length of the string.

Using this new Get String Length merge, the string’s length will be returned as shown below.
stringlength
 

Additional Resources