Alteryx Designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
The Expert Exam is now live online! Read about the specifics and what it took to bring it to life in the blog by our very own Elizabeth Bonnell!

Prevent Run Command Trying to Execute Non Existent Script

Highlighted
7 - Meteor

Hi,

 

I have an Alteryx workflow that contains filters to branch data and some of the branches use the records to create dynamic script commands using the Run Command.

When there is data everything is fine, however when a filter results in zero records going down the 'true' route, the run command still fires and fails with an error as no commands have been written to the batch script.

Below is a simplified version to demonstrate the issue:

 

Capture1.JPG

Capture2.JPG

 

Is there any way of preventing the execution of Run Command or any other macro when there are zero rows to process?

 

Thank

Steve.

Highlighted
11 - Bolide

Hi @SME_Steve

 

I recently had a similar issue with a dynamic input tool which was updating a SQL query. When there were 0 records, the workflow would fail. In the end I had to use a combination of a detour tool and a text input to provide a dummy row of data to the dynamic input tool which I then filtered out afterwards. 

 

Below is a link to the article I used for inspiration. Hopefully that helps.

 

https://community.alteryx.com/t5/Alteryx-Knowledge-Base/CS-Macro-Dev-Conditional-Processing-with-Det...

Highlighted
7 - Meteor

Thanks @DataBlender,

 

That approach was one of the options I'd been thinking about - as far as I know, detour is the one thing that can prevent a certain path being executed, so thanks for the link to the example.

What makes my case more complex is that my scripts are being built and executed dynamically and conditionally within an iterative macro. Some things I build and execute on first iteration but I don't want them to run in later iterations and I'm trying at this stage not to push things deeper into sub macros to control the flow.

As it's just the RunCommand that's giving the problem I'm going to take a different approach and have a prebuilt 'runner' script. This will check for the existence of each 'action' powershell/script before executing it. The workflow/iterative macro will create the 'action' scripts but execute the 'runner' script (which is always there). If the 'Action' script isn't present the 'Runner' will just exit nicely without a 'file not found' error getting thrown by Alteryx. I need to figure out some details on when to delete all existing 'action' scripts especially with the iterative nature of the macro but this should work ok.

I'll keep your example in mind if my script approach falls flat! 🙂

 

Thanks

Steve.

Highlighted
6 - Meteoroid

Hi,

 

I faced a similar issue in the following "file cleanup" workflow with the run command prompt returning an error code of 1 when no files were present to delete (e.g., no files older than 90 days).

 

I solved this by unioning a text input tool containing "exit b/ 0" as a single record just prior to the command prompt to ensure there is always a script to execute. Although the batch script continues to execute, the string "exit /b 0" results in the script exiting and returning no error code (always returns 0).

 

I found other solutions out there to solve this problem, mostly more complex, but this worked in my situation thanks to a tip from @MarqueeCrew in the following thread: https://community.alteryx.com/t5/Alteryx-Designer-Discussions/Catch-Error-Result-from-Run-Command/td...

 

VizAlly_0-1592247595158.png

 

Labels