File Trigger
If you want to start a Process when a certain File appears on a directory, you can use the File Trigger. File Triggers are triggered when a file matching the File filter is saved to the Directory path to watch.
The Trigger watches for new files added to the watched directories, e.g. a newly created file will cause the Trigger to launch a Process, but if that file is left in the directory and modified, that will not cause a new execution. The file watch also checks the files in the directory every 10 seconds.
The Trigger keeps track of files it has already processed by their file names. This means that it will not notice if you e.g. overwrite the file, or quickly delete a file and then create a new one with the same name. It may take up to the max poll delay of 10 seconds to notice a file has been removed.
It is recommended to always clear the files from the watched directories after processing, because keeping track of them takes up resources. If you would have thousands of files in the folder, the processing may slow down.
In a HA Agent Group, the watched directory should be accessible from all the Agents in the same Agent Group. Otherwise the other Agents will see the file as missing from the watched folder and remove it from tracking causing the file to be processed again.
The following parameters can be defined for the File Trigger. Directory is the directory path where the files will be fetched. File filter defines the mask (e.g. '*.xml') with the possible wildcards. The Include sub directories flag makes the Trigger fetch all the matching files from the subdirectories if enabled. Maximum number of files to process at a time defines the maximum number of files to process at a time while the maximum is 1000. Poll interval in seconds is the time before the files are processed again. Quiet period in seconds is the wait time in seconds since the last time a file was written to before processing a file. Username and Password are to be used when the Trigger is not using the Frends Agent account credentials to access the directory.
File Trigger parameters, especially Name
and Directory
, are not Text or Expression fields familiar from the other Process Elements. Instead they behave like Text fields, with the exception that you can use Environment Variables without handlebars. For example if you have C:\EaiFiles
stored in environment variable #env.EAI
, then you could have Directory
configured as #env.EAI\In
. It would then watch the folder C:\EaiFiles\In
.
Referencing Trigger parameter values
Once the Process is triggered by a file, the file paths become available to the Process via the #trigger.data.filePaths
. It is array System.Object[] containing strings (file paths). For more details, there is also the #trigger.data.files
reference, which returns an array of objects with the following properties: FileChangeType, FullPath, FileName.
The next article is Introduction to API Trigger