Using CSV Repeaters
In this tutorial, we will demonstrate how to use the CSV Repeater task and the Context Variables it produces to store unique information for a variety of records.
CSV Repeater
In this example, we will be working with the following example CSV:
AccountReference,Name,OutstandingBalance
"CUST001","Customer 1","42.00"
"CUST002","Customer 2","10.00"
"CUST003","Customer 3","653.00"
In this example, we will use the following task settings. Any settings not mentioned can be left at their default values:
- Input - The CSV file to use. Set this as the name of the CSV file
This gives us access to AccountReference, Name and Outstanding Balance for each record in the CSV file as Context Variables.
Next, we can use the Razor Template task and these Context Variables to create personalised text files for emailing. It is important to ensure that the Razor Template is nested within the CSV Repeater task. This can be achieved by dragging the Razor Template on top of the CSV Repeater task. When successful, you will notice the Razor Template task appears indented.
In this example, we will use the following XML as the template for the Razor template task:
Dear @(Context.Current["Name"]), your outstanding balance is @(Context.Current["OutstandingBalance"]).
Please bring your account up to date at your earliest convenience.
Sincerely,
Test Company
For the Razor Template task, we will use the following task settings. Any settings not mentioned can be left at their default values:
Output File - The file to save successful records to. In this example, we will set this to:
@(Context.Current["AccountReference"]) email.txt
. Please ensure that you click on the ellipsis and tick the "Use Razor Engine" checkbox.Template File - The file containing the template to use. This should be set as the file containing the above Razor Template.
If we run the workflow now, 3 files are created:
- CUST001 email.txt
- CUST002 email.txt
- CUST003 email.txt
Here is an example of the contents of CUST001 email.txt
Dear Customer 1, you're outstanding balance is 42.00.
Please bring your account up to date at your earliest convenience.
Sincerely,
Test Company
This is just a few of the ways Context Variables can be used in an integration, but it should hopefully give you some insight into the other types of operations that can be carried out.