Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.

Stop a workflow when no files in a directory


I have read the KB article about stopping a workflow on a condition.  But, the example doesn't work for me.  What I need to do seems simple.  I want to look at a Windows folder.  If there are files present then continue.  If there are no files present, stop.  


Any suggestions?


Solved it


Can you please post the solution here. Would be helpful, I am looking for same kind of solution.


Here is a really simple workflow that seems to work.  From the canvas you need to configure the runtime environment by checking the box next to "Cancel Running Workflow on Error".


The workflow process:

1) The Directory tool looks at c:\temp2  (change to whatever folder you need to examine)

2) The Count Records tool counts the results of the Directory tool and puts the value in a variable called Count.

3) The Block Until Done tool pauses processing and steps through the output anchors in order.

4) The Test tool is processed first as it is coming off the #1 output anchor of the Block Until Done Tool. The test anchor is configured to look if Count is >0.  Note: Test Type is configured as "Expression is True for All Records" since only one record is returned for testing.

5) The process continues out of anchor #3 of the Block Until Done Tool.  In this case to write a file to c:\temp3.  This tool can be replaced by anything you want to continue your work flow.  


Test the workflow by creating a Temp2 and Temp3 folder off of your c: drive.  Then run the flow with temp2 empty.  It should error out and nothing is written to temp3.  Then, place any file in temp2 and run the flow.  It should complete write a file to temp3.  In production I replace writing the file in temp3 to a conditional runner to start a workflow.


Hope this helps.