Last Updated: 08/11/2016Introduced in Verision: 2.0
This example simulates the lookup of a customer’s account balance. The NVelocity step uses conditional statements to evaluate the account balance dollar amount and produces a custom message to communicate the account holder’s “status” with the company based on the evaluation (either “Standard,” “Classic Plus,” or “Premium”). The string message output is used to populate an email body sent to the customer.
First, in a Designer Folder, create a new flow.
In this example, a Create or Copy Data component is used to provide a constant, numeric value to simulate an account balance. In a production environment, this could be a database lookup of an account balance. The Create or Copy Data step is found in the Toolbox under the Data category. Drag and drop this component into the workspace. Connect the Start step to the Create or Copy Data step.
Click on the Create or Copy Data step, and from its Properties panel, configure it as follows:
Next, add the Custom Merge [NVelocity] component. From the Toolbox, expand the Data > Text category. Drag and drop the Custom Merge [NVelocity] component following the Create or CopyData step. Connect the Create or CopyData step to the Custom Merge [NVelocity] step. Click on the Custom Merge [NVelocity] step.
From the Properties panel, under Merge Setup, type the message to communicate to account holders. For example:
The conditional statements use the following syntax:
You can register now to get the great benefits of membership!
Welcome back $User.UserName!
Additionally, the for each statement supports additional features to enable things like alternating rows, headers, and footers:
#foreach($i in $items)
text which appears for each item
text which appears before each item
text which appears after each item
text which appears between each two items
text which appears for every other item, including the first
text which appears for every other item, starting with the second
Content rendered if $items evaluated to null or empty
text which appears before the loop, only if there are items matching condition
text which appears after the loop, only of there are items matching condition
As variables (i.e. $accountbalance) are entered in the Template field, the MergeInputData field populates. For each variable defined, click on the variable in the MergeInputData field, and click the Edit button. Set the appropriate data type and click OK.
Lastly, to complete the configuration of the Custom Merge [NVelocity] step, select the accountbalance Input data (which is the output of the Create or Copy Data step). This is the integer that will be evaluated by the Custom Merge [NVelocity] step.
To complete this example, the flow will send an email containing the membership status message represented by the output string of the Custom Merge [NVelocity] step, MergedString. From the Toolbox, expand the Communication category and drag and drop a Send Email step into the workspace. Connect the steps as follows to complete the flow:
Configure the email To, From, and Subject line information, and in the Body field, select the Text Merge Plain option. Add the MergedString variable to the Merge Text Editor.
When the flow runs in the Debugger, an email is sent displaying the membership status as “Classic Plus” since the account balance amount is set to 1,000. Change the value of the Create or Copy Data step to different numeric values to see the other if statements of the NVelocity step applied.