community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx Knowledge Base

Definitive answers from Designer experts.
Upgrade Alteryx Designer in 10 Steps

Debating whether or not to upgrade to the latest version of Alteryx Designer?

LEARN MORE

Stop workflow on a condition

Alteryx
Alteryx
Created on

Sometimes you may want to stop a workflow if certain conditions are met!

 

Luckily within Alteryx we have the combination of the Test Tool and Workflow Properties to stop the workflow.

 

A common use case is you have scheduled workflow with an input file which is updated each week, but sometimes there is no new data. You would like to stop the workflow outputting and overwriting your output file if there are zero records in the workflow. In this particular use case you will want to add a count and test tool before your output tool to make sure no records pass to the output tool.

 

Adding a count tool will give you the value you need to see if any records are present in the workflow. If the count is 0 it means there no records present, if it greater than this there are records present and you would like the workflow to continue as designed.

 

When you attach the test tool to the count tool, you will need to hit the ‘Add’ button to create a test scenario.

 

Pic 1.png

 

When you hit add it will pop out another window.

 

Pic 2.png

 

In this window you can enter your test name which will populate in the results window error log. The input connection is the data stream. And the Test type reflects the type of test you would like to apply. In this particular example we will be using ‘Expression is True for All Records’.

 

Pic 3.png

 

The Test value field will give you a window similar to the formula tool. In here you can create your expression. The test tool works when a user-specified condition is not met. Therefore, the in this particular case I am looking for no data so having count less than 0 will error when there is no data available.

 

Once you have configured the test tool and attached it in the workflow. You need to click on the canvas and navigate to ‘Runtime’ in the configuration window. In here there are a list of tick boxes, you will have to tick ‘Cancel workflow on error’. This will work in tandem with the test tool to cancel the workflow when the error is generated.

 

Here is a screenshot of the sample workflow.

 

Pic 4.png

 

 

I have also attached the example workflow! (Built in Alteryx Designer v10.1)

 

Attachments
Comments
Alteryx Certified Partner

Dear @JordanB.

 

is there also a way to not throw errors if a scenario is met. I am checking an API for updated data and everything works fine if there is new/ updated data. If there is nothing new however, I get an error and an email because of this error.

 

I would like to use the scenario you described but terminate the workflow right after this test without throwing an error.

 

The reasoning behind this is, that an error means something has gone wrong and I need to check my workflow. If a predefined scenario like "No Records" however is present I do not need to check because everything works like it is supposed to.

 

Best Regards

Martin Pohlers

Alteryx
Alteryx

Hi @MPohlers

 

You can use the message tool instead of the test tool to select another message type other than error to satisfy your condition above.

 

Best,

 

Jordan Barker

Solutions Consultant

Alteryx Certified Partner

Hello Jordan,

 

could you please provide an example?

 

I am not sure about the following points:

- How to set a condition like "Zero Records" in the message tool

- How to stop the workflow without throwing any error when this message is received

 

Best Regards

Martin Pohlers

Alteryx Alumni (Retired)

I have exactly the same issue as @MPohlers, I need to stop gently without error a macro when no record is found, because of unpredictable APIs...

 

Also, your article does not explain which Workflow Property to set...

Alteryx
Alteryx

Hi @MPohlers & @FredericP

 

In this scenario I would recommend using the Crew Macros and the conditional runner.

 

You can have one workflow which checks to see if the data has been updated. You can cause this workflow to fail if it doesn't need updating, and succeed if it does. This will avoid you getting errors in the master workflow.

 

In the second workflow you can have it set up to run the update URL workflow from the success node of the first conditional runner.

 

Capture.PNG

 

Best,

 

Jordan Barker

Solutions Consultant

 

 

Aurora
Aurora

This is very useful @JordanB - thank you.  

Here is a case where I know the tool well, and have exactly this problem to solve (trying to deal with an error that is predictable in certain circumstances - the error happens when zero rows are returned from a dynamic query, so it's safe but still generates a messy outcome in the run logs) but never put 2 and 2 together to use the message tool to terminate the flow before the error without an error flag and thereby do a clean termination.

 

 

Sometimes just needs someone else's eyes on the problem

 

Thank you @JordanB - gonna use this today!

Atom

How to Change error message if directory tool does not found any file at given location?

My App return Error message.

Capture.PNG

 

I want to Change this error message

Alteryx
Alteryx

Hi @Shivang

 

A user can first select the folder directory where the file resides. 

 

You can then have a user use a text input to update a filter looking for that file

 

You can then use a count tool to count the number of records coming out of the filter. This will tell you if that file exists or not.

 

Based on this you can add a message or test tool to say if [count]=0 then Error and say 'File not found' or whatever message you would like. 

 

In my example I have used a message tool, as I thought it would be cool to add the message in, however if that file exists then to allow the directory information to pass through so you can continue to read that data source in.

 

Filenot found.PNG

 

 

More description inside of the attached workflow (You will have to update the directory & filter tool to match your data)

 

workflow.PNG

 

Workflow built in 11.5

 

Best,

 

Jordan Barker

Meteor

 Hi Jordan,

 

Thanks for posting, I was wondering if you have another example, or can help round

it out to a date based issue where we don't want a full workflow " cancel"but to split the process based on

true/false of some condition and handle it 2 ways. 

 

In this case, what if you have source 1 (and in data base connection) where you check

the max date called max_dt_source

 

Then you have source 2 (lets say your original output file)  that is max_dt_existing.

The business check would be IF max_dt_source > max_dt_existing then < run full process/ as a macro > 

else send an email saying "there was no new data for today". 

 

I have tried both options you listed above an my issues were as follows:

i can't use a 'test' since i don't want to cancel the workflow, i want it to send that email "no new data" for today

to the write people (alteryx server). I can't use the running crew macro since there is no other process that would be running.

I also tried an input macro and that doesn't work either. I currently have the workflow set up and append fields

and then compare the two dates. coming off the TRUE i have another check for the data is non null. coming off the false

i have the email all set up and ready to go. my issues is that even though there is only 1 record and 0 on the other side

both processes run. I also friend filters to ID a null, but it still runs both the FALSE and the TRUE process.

 

Thanks very much for your help,

 

Mallory

 

Atom

Hello, I have similar doubt about stop the workflow but, not generated by an error, I need a partial stop, I mean; I have a flow with two different ways to take, based on a filter, I need to stop totally the first way  if the filter take the second way or viceverse, stop totally the second way if the filter take the first way; thats because with the filter, the second option continue moving and create output files with empty info and I need to keep the originals until I run again and the conditions change to overwrite that files.

 

I tried Action Tool but I don't know how it works based on a condition coming from a filter.

 

Flow_to_stop.JPG

Alteryx
Alteryx

@RaulO - You will want to put the different paths inside a batch macro and use either detour tools or tool containers and actions to turn each section on and off with a control parameter.  Outside of the batch macro you can use either the filter tool or (maybe easier) a formula tool to pass a value into the control parameter of the macro which is then used to tell the action tool what to do. 

 

I suggest reading this article

Atom

Thanks CameronS,

 

I tried with the example in the article but I don't know how to aply it, I did some tests and changing my flow but alll the time goes in the same way, the condition could be false but anyways runs left.

 

Do you have some example that can share?, with action to close or disable the container tool.

Meteoroid

I have similar problem. I want my workflow to stop processing on No File Found.

1. Workflow has an email event - send email on error. to notify owner that workflow has failed.

2. if I fail workflow on my given condition using message tool - error and stop further processing, then event in step 1 triggers and send email which is undesirable.

 

I want event in step 1 triggers on workflow errors excluding user initiated error as in step 2.

 

Is there any way to control Events dynamically?

Say, on a given condition I can disable a Workflow Event?

Or may be Message Tool can have another option - Stop Processing without Error or Stop Processing with Warning

 

 

 

Alteryx Certified Partner

@saqibahmad- this is what I am looking for, too!

Asteroid

Hello, I have the same requirement in that I want to stop the workflow if no records.

The only issue I have is that I am using a batch macro, which I am chaining in a workflow with several others.

 

Stopping on the test results doesn't work within a batch macro as I don't then have the runtime tab.

 

I am also not using the crew macros as I schedule via the gallery

 

any advice would be much appreciated

 

Steve