Please enable JavaScript to view this site.

InterFormNG2 Manual

You can use InterFormNG2 to generate a list of all files in a specific directory (and even include files in sub-directories) and output the list as an XML file.

This can be done with the advanced, utilities workflow component called: List filesystem directory. The component outputs the list as an XML file into the payload of the current workflow.

 

A related workflow component is: List resources. This can e.g. be considered in environments, where direct file access is not allowed.

 

The List filesystem directory workflow component has these parameters:

 

NG2WorkflowListFilesystemDirectory01

 

Directory

This is the directory, where all files should be listed from.

 

Recursive scan

If this not selected (which is default), then only the files in the main directory are listed. If this is enabled, then all files of the sub-directories are also included.

 

If you want to verify the result, then you can use the To filesystem component to save the output XML file. It might be a good idea to save the payload e.g. into a named property with the component, Payload to named property before the List filesystem directory and then later use the component, Named property to payload to restore the original payload.

 

This XML file can be used in additional processing in the workflow e.g. to merge it with another XML file, by first running the List filesystem directory component and then use the component, Payload to workflow variable to save the XML and then later merge the XML files in a transformation, that use this variable.

 

 

The resulting XML file looks like this:

 

<?xml version="1.0" encoding="UTF-8"?>

<files>

  <file>

     <name>Demo.splf</name>

     <path>C:\ProgramData\InterFormNG2\resources\home\document</path>

     <absolutePath>C:\ProgramData\InterFormNG2\resources\home\document\Demo.splf</absolutePath>

     <uri>file:/C:/ProgramData/InterFormNG2/resources/home/document/Demo.splf</uri>

  </file>

  <file>

     <name>Intro_demo - Excel formula.xml</name>

     <path>C:\ProgramData\InterFormNG2\resources\home\document</path>

     <absolutePath>C:\ProgramData\InterFormNG2\resources\home\document\Intro_demo - Excel formula.xml</absolutePath>

     <uri>file:/C:/ProgramData/InterFormNG2/resources/home/document/Intro_demo%20-%20Excel%20formula.xml</uri>

  </file>

</files>

 

 

Here are a couple of examples, which illustrates how the workflow component, List filesystem can be used:

 

Example 1: Send an email with multiple attachments

Example 2: Add on: Only send the email if any attachments was found.

 

If you want to collect attachments and send emails for multiple customers, then you should refer to example 4 for List resources: Send email to each customer with all waiting PDF files. The principle is the same, the node names and contents are only a bit different.

 

 

 

Example 1: Send an email with multiple attachments

The list filesystem workflow component can be used if you e.g. want to collect all waiting PDF files in a folder and add the PDF files as attachments to an email. A prerequisite for this is, that InterFormNG2 is allowed direct access to the file system. If access to the file system is not an option, then you can consider to store the PDF files as resources e.g. in the other folder of the library and instead use the List resources component.

 

Below you can see an example of how this can be done with List filesystem directory:

 

NG2ListFileSystem002

 

 

Each component with its configuration are listed below:

 

The first is the configuration of when the workflow should start. This is here setup with the workflow input type, Scheduled start and in this case the workflow starts up each day at 5:00 pm (17:00):

NG2ListFileDSystem003

 

 

Next the contents of the monitored folder are listed into an XML file in the payload with the workflow component, List filesystem as below:

 

NG2ListFileSystem004

 

The option 'Recursive scan' is deactivated, so the output XML file only lists the files in this folder - not sub-folders.

 

The choice and join workflow component is added as a way to collect all the attachments and keep them for the email. It contains a dummy condition (1=1) to ensure, that the branch is always executed. The choice and join is setup like below:

 

NG2ListResources005

 

The otherwise branch has been deleted as it is not needed.

 

 

In the top branch of the choice and join the first function is a split xml workflow element. It is to split the XML file, which was created by the List filesystem directory element earlier (which still is in the payload). The split definition is to split up the xml for each file, that has been found and that is done with this setup:

 

NG2ListFileSystem006

 

Splitting on the node /files/file makes the split xml function create one XML file for each file found in this format:

 

<file>

     <name>Intro_demo - Excel formula.xml</name>

     <path>C:\ProgramData\InterFormNG2\resources\home\document</path>

     <absolutePath>C:\ProgramData\InterFormNG2\resources\home\document\Intro_demo - Excel formula.xml</absolutePath>

     <uri>file:/C:/ProgramData/InterFormNG2/resources/home/document/Intro_demo%20-%20Excel%20formula.xml</uri>

  </file>

 

The option 'Collect attachments' has been enabled, which will ensure that attachments, that are created while splitting are saved and can be referenced later.

 

Now we can refer to the smaller, splitted XML in the next workflow component, File to attachment, which is setup like below. This component adds an attachment for each file found.

 

NG2ListFileSystem007

 

Here we use Xpath expressions based on the small XML file seen after the split xml component.

 

Now that we have added the attachment we no longer need the file that was converted into the attachment. So we could now choose to delete the file (and e.g. consider to save a backup if needed).

Here the file is deleted with the component, Delete file:

 

NG2ListFileSystem008

 

The last element is found in the join branch of the Choice and join component. Here we can finally send out the email with the workflow component, Send an HTML email like below:

(The difference between this component and Send PDF email is, that the Send an HTML email component only includes attachments, that has been prepared before the component is run, where the component, Send PDF email always will merge the XML (or spooled file) in the payload with a template and attach that.)

 

NG2ListFileSystem009

 

(Here the email is held - for testing).

 

There is only detail missing: You probably only want to send out the email if at least one file was found. Such a condition is added in the example below.

 

 

Example 2: Add on: Only send the email if any attachments was found

This example is based on the first example above. This is an add on to show how you can ensure, that the email is only sent, if at least one file has been found in the monitored folder.

 

One way to do that is to add a condition (choice element) immediately after the List filesystem directory component like below:

 

NGListFileSystem010

 

The Otherwise branch of the extra choice element has been deleted as that is not needed. The condition in the new choice can look like this:

 

NG2ListFileSystem011