Altova FlowForce Server 2025 

This tutorial explains how to create a job that copies files with a particular pattern from one folder to another. Let's assume the Sales department daily receives various purchase orders for books and needs to share some of the files with the Accounting department. We will create a scheduled job that will copy only JSON files with the BookList prefix to the Accounting folder.

 

Currently, the folder of the Sales department contains the following files:

 

Authors.xml

Authors.xsd

BookCatalog.xlsx

BookList.csv

BookListBiography.json

BookListChildren.json

BookListClassics.json

BookListCrimeMystery.json

BookListFantasy.json

BookListHorror.json

BookListHumor.json

BookListSciFi.json

BookOrder.txt

BookOrder.xml

BookOrder.xsd

Books.json

Books.schema.json

FileList.txt

Notes.txt

ORDERS.EDI

 

This list contains sample files that we have created for this tutorial. These files are used for demonstration purposes only. Please use your own files to test the functionality described in this tutorial.

 

The broad outline is described below:

 

1.We will create a new job in the /public/Examples container.

2.After that, we will add a For-Each step that will iterate through a sequence of files and copy them from the source folder to the target folder.

3.Then we will configure a timer that will trigger the job according to a specific schedule.

4.We will also select an existing password credential, with which the job will be run.

5.After saving the job configuration, we will observe the status of the job on the Home page. After successful execution, we will be able to see the copied files in the destination folder.

 

Implementation

This subsection describes step-by-step instructions on how to create the job outlined above. The implementation of this scenario is also shown in the GIF file at the bottom of this topic.

 

Step 1: Create a job

To create a job, follow the instructions below:

 

1.Log on to FlowForce Server.

2.Navigate to a container where you have the permission to create new jobs. For testing purposes, we will be using the /public/Examples container. If this container does not exist yet, create it using the Create | Create Container command.

3.In the /public/Examples container, create a new job by clicking Create | Create Job.

4.Enter a job name (e.g., SampleJob), and, optionally, a job description.

 

In our example, the job is called CopyFiles and contains the following description: "Copies files from Sales to Accounting."

 

Step 2: Add a For-Each step

For-Each steps enable you to iterate through a sequence (e.g., a list of files in a directory). A For-Each block, which may contain multiple steps, is executed until FlowForce Server finishes looping through all the items of the sequence expression. To configure a For-Each step, follow the instructions below:

 

1.Click New For-Each Step in the Execution Steps section, which causes a For-Each block to appear.

2.In the Sequence text field, we will supply the following expression:

 

list-files('C:\Test\FlowForceServer\CopyFiles\Sales\BookList*.json')

 

The file-system function lists JSON files with the BookList prefix located in the Sales folder. The * sign means that anything can come after the BookList prefix. All the other files in the folder will be ignored.

 

3.The next step is to add an Execution step inside the For-Each block: Click the plus icon inside the block and then select New Execution Step from the list.

4.Enter the /system/filesystem/copy function in the Execute Function field.

5.Set the Source parameter to {item} - this refers to the value specified in the For Each field. The value in the For Each field means that for each item in the sequence a certain action will be performed. In our example, each file matching the pattern in the Sequence field will be copied to the Accounting folder.

6.Set the Target parameter to the following path: C:\Test\FlowForceServer\CopyFiles\Accounting - this is the path of the target directory to which the files will be copied.

7.Enable the Overwrite option - this will enable FlowForce Server to overwrite the files that already exist in the destination folder.

 

Thus, the For-Each step will loop through the list of files in the Sales folder and copy only the JSON files with the BookList prefix. If there are files in the Accounting folder that match the files that are being copied, the destination files will be overwritten.

 

Step 3: Configure a timer

Since one of our goals is to run the job according to a particular schedule, we need to set a timer that will trigger the job. To add a timer, take the steps below:

 

1.Navigate to the Triggers section and select New Timer.

2.Set the Run option to Daily.

3.Set the start date and time in the Start parameter.

4.Make sure the Enabled check box is selected.

 

Step 4: Select a credential

When you create a job in FlowForce Server, you must supply the credentials of the user account with which the job must be executed.

 

In the Credentials section, we will select a password credential that we created before starting this tutorial. This is a standalone credential object that you can use in any job. Standalone credentials are convenient, because you can change them in one place, and this change will affect all jobs that use that credential reference.

 

Alternatively, you can specify a local credential, by entering your user name and password.

 

For more information about types of credentials and instructions on how to create them, see Credentials.

 

Step 5: Save the job and monitor its status on Home page

Click Save at the bottom of the configuration page. Click the Home tab to go to the Home page. The Home page will display the newly configured job in the Active Timers section. As soon as the job is triggered by the timer, the job may appear in the Running Jobs section for a short time. For more information about monitoring job statuses and statistics, see Job Info on Home Page and Job Statuses.

 

Job outcome

After successful execution, all the JSON files with the BookList prefix will have been copied to the Accounting folder:

 

BookListBiography.json

BookListChildren.json

BookListClassics.json

BookListCrimeMystery.json

BookListFantasy.json

BookListHorror.json

BookListHumor.json

BookListSciFi.json

 

If the execution of the job fails, check the FlowForce Server job log to identify the issues.

 

Implementation shown in GIF

For a quick demo of the steps described in this tutorial, please click the GIF file below. Note that only Steps 2, 3 and 5 are illustrated in the GIF. For an illustration of Steps 1 and 4, see the Hello World tutorial.

Click to play

 

© 2018-2024 Altova GmbH