Please enable JavaScript to view this site.

InterFormNG2 Manual

Navigation: Workflow > Workflow examples

Workflow: How to move files into an error folder

Scroll Prev Top Next More

When InterFormNG2 is processing files from a folder, then it will process the input files like so:

 

NG2WorkflowErrorFolder0001

 

The files are moved into the processing folder, when InterFormNG2 starts to process the files, and they are moved into the processed folder, when they have been processed, no matter if the processing ended in error or not.

 

You might prefer, that InterFormNG2 should work like this:

 

That the files are moved into different sub-folders depending on if an error was found or not. In this way only successfully processed files are moved into the processed folder, while files that hit an error are moved into an error folder like below:

 

NG2WorkflowErrorFolder0002

 

You can achieve the above, if you setup the main workflow and an error workflow like shown below:

(On the main workflow we setup a reference to the error workflow, which is shown below).

 

NG2WorkflowErrorFolder0003

 

This is all described in the video below, but the details are also covered below the video:

 

 

 

You need to setup both the main workflow and the error workflow in a specific manner:

 

The main workflow:

1.Refer to the error workflow in the header.

2.Save the input XML file in the payload as a named property.

 

 

The error workflow

1.Restore the XML file to the payload from the named property.

2.Save the XML file in the error folder via the To filesystem component.

 

 

The main workflow

The main workflow can be built up by these components:

 

In the bottom of the first component, Read from file you can refer to the error workflow to call, if an error should occur:

 

NG2WorkflowErrorFolder0004

 

In the next component you should save the payload to a named property e.g. like below:

 

NG2WorkflowErrorFolder0005

 

And then you can continue to setup the workflow as normally. You can even at any time select another error workflow with the component, Error handler.

 

 

The error workflow

The error workflow consists of the 3 components below:

 

First the input type:

 

NG2WorkflowErrorFolder0006

 

Now the error workflow is to retrieve the original payload with the Named property to payload component:

 

NG2WorkflowErrorFolder0007

 

And finally the error workflow can save the payload to the error folder with the to filesystem component:

 

NG2WorkflowErrorFolder0008

 

 

The output directory is found with this dynamic Xpath expression:

 

concat(substring-before($interform.input.file.absolute.path,'processing'),'error')

 

It starts with the function, substring-before($interform.input.file.path,'processing') in this function the workflow variable, $interform.input.file.path contains the full path of the file, that InterFormNG2 is currently working on. This can e.g. be C:\ProgramData\InterFormNG2\inbox\processing\Intro_demo.xml.

 

With the substring-before function the path to the left of 'processing' is cut out, which results in this in our example:C:\ProgramData\InterFormNG2\inbox\

 

Finally we need to add the text 'error' at the end with the concat function, which makes the new path: C:\ProgramData\InterFormNG2\inbox\error