Using File Repeaters
In this tutorial, we will demonstrate how to use the File Repeater task and the Context Variables it produces to store and use unique information for a collection of files
File Repeaters
File Repeaters are slightly different to the other repeaters we provide. Where other repeaters are concerned with the information contained within a file, the File Repeater can be used to perform operations on the files themselves. Here is an example of how this can be used.
For this example, we are using C:\Input
as a directory containing Sage 50 Sales Orders.
Within this folder, we have the following Sales Orders:
- sales_order_1.xml
- sales_order_2.xml
- sales_order_3.xml
On the File Repeater task, we can use the following settings. Any settings that aren't mentioned can be left as their default values:
- Input Directory - The directory you want to enumerate. This should be set to
C:\Input
Next, we need to drag the Sage 50 Import Sales Orders task on top of the File Repeater task.
This task would need the following settings. Any settings that aren't mentioned can be left as their default values:
- Fail File - The XML file to save records which failed to import into Sage. This should be set to
@(Context.Current["NameWithoutExtension"])_fail.xml
- Input File - The XML file containing the records to import into Sage 50.. This should be set to
@Context.Current["FullName"]
- Success File - The XML file to save records which successfully imported into Sage. This should be set to
@(Context.Current["NameWithoutExtension"])_success.xml
It is essential that for each of these you click the ellipsis next to each field and ensure the "Use Razor Engine" checkbox is ticked.
Next, we can add a Move File task to move the processed records to C:\Processed
The settings for this task are as follows. Any settings that aren't mentioned can be left as their default values:
- Input File - The file you want to move. This should be set to
@Context.Current["FullName"]
- Output File - Where you want to move the file to. This should be set to
C:/Processed/@(Context.Current["Name"])
Again, it is essential that for each of these you click the ellipsis next to each field and ensure the "Use Razor Engine" checkbox is ticked.
When ran, the workflow will now look in C:\Input
, try to import any files it finds to Sage, then move the original file to C:\Processed
while retaining it's original file name. The Success and Fail files from the Sage import will remain in the working directory for archiving, but will have names that a relevant to each file. This also ensures that these files aren't overwritten if there are multiple records imported on a single run.