Filename Variable

Filename Variable Node

Purpose

Sets a workflow runtime variable called ‘Filename’ that can be used by the other workflow nodes to reference a particular file.

Filename Variable Node

Usage

Each workflow contains a variable called ‘filename’. This variable can be set to a particular ‘real’ file name during the execution of a workflow and then used in various nodes. This is useful when you don;t know what the exact name of the file is going to be when you are designing the workflow but you have set set paths and filename when configuring nodes.

For example. Say you have a workflow that takes an uploaded file and copies into a working folder for processing. The problem is that the finance department set the name of the file and it changes every day. You don’t know exactly what the file is going to be named so how do you configur the copy node? Well you can use the filename variable to make this job easy.

How the Filename is Selected

To select a file name you select a directory on the Paygate server and provide a filename. The filename can contain a wildcard pattern.

When the workflow runs the node will scan the directory and create a list of all files matching the wildcard pattern. By using the order crieria and direction settings you can control which file is picked. For example, if you always what to pick the oldest file first then set the Order Criteria to ‘Creation’ and the Order to ‘First’. When the node is executed as part of a workflow, all of the matching files in the selected folder will be ordered by creation date and the oldest file is used to select the filename variable.

Bahaviour if no files are matched

If no files match the search criteria then the filename variable is not set. In this scenario the path of the workflow continues down the ‘None Found’ output of the Filename Variable node and the Status of the Filename Variable event will be ‘Warning’.

How to use the Filename Variable

Once the filename variable has been set, it can be referred to in other nodes. Usually in the filename textbox. To use the filename variable in another node in the workflow use the text:

{filename}

Most nodes in Paygate Workflows that use a filename as input can use the filename variable. For example, using a move file node to move a file from one directory to another.

Filename Variable Usage

Enter {filename} in the filename text box will cause the move node to replace {filename} with the value of the filename variable.

Configuration

Filename Variable Node

Filename

The name of the file(s) that will be used to set the filename variable. This can be either:

Wildcards

Standard * and ? wildcards are fully supported allowing you to copy all files matching a particular wildcard pattern.

The node can also use more advanced Wildcards such as those based around ranges: […]

Wildcard Description Example Matches Does not match
* matches any number of characters myfile.txt myfile.txt or myfile.csv myfile1.txt
? matches a single character myfile?.txt myfile1.txt myfile22.txt
[abc] matches one of the characters provided [pf]ile.txt file.txt, pile.txt mile.txt
[a-z] matches one character from the range provided myfile[0-9].txt myfile1.txt, myfile2.txt myfile10.txt

Additionally use can use the ! character to apply ‘not’ logic

Wildcard Description Example Matches Does not match
[!abc] matches one of the characters NOT provided [pf]ile.txt mile.txt file.txt
[!a-z] matches one character NOT from the range provided myfile[0-9].txt myfilea.txt, myfile22.txt myfile1.txt

Folder

The logical path of the directory containing the file. You can use the folder browser functionality to set the folder if required.

Order Criteria

The criteria used to order the files in a directory.

Criteria Description Sort Type
Name Filename Alphabetic
Creation File Creation Date Date
Last Access The file’s last access date and time Date
File Size Size of the file in bytes Numeric

Order Direction

The direction of the ordering process. For example, if you shoose ‘Last Access’ as your sort criteria. Settign this value to first will order the first by file that were access most recently first. I.e. the first that was access most recently is set to the filename variable.