Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Server Discussions

Find answers, ask questions, and share expertise about Alteryx Server.
SOLVED

Command line event to execute another workflow does not work

bhanu5
7 - Meteor

The command line examples to execute 1 workflow after another works when I test it for running 2 workflows but it errors out at the end.

 

Error: Designer x64: The Designer x64 reported: Error running Event #1: The external program "C:\Program Files\Alteryx\bin\AlteryxEngineCmd.exe" returned an error code: 1: The system could not find the environment option that was entered. (203)

 

I ran the below command manually in command prompt on the server and I get the same error as of the gallery/designer.

Command: AlteryxEngineCmd.exe "C:\files\1.yxmd"

 

I am assuming the AlteryxEngineCmd.exe is trying to access system environment variables and they might be different than what it is expecting or such environment variable does not exist. What could it be?. Can someone please shed some light on this? This question is asked in numerous topics and NO ONE answered this.

5 REPLIES 5
ntobon
Alteryx
Alteryx

@BH Can you add the Alteryx root path to your Path System Variables on your computer and test it ? 

Reference: https://help.alteryx.com/current/designer/run-workflows-command-line

 

 

Also, are you  are licensed for automation (which includes using the Alteryx command line). You can check under License Manager.

ntobon_0-1589828683710.png

 

If not, it is a licensing issue and you should check with your Alteryx account manager.

 

 

 

bhanu5
7 - Meteor

Thanks for the reply. I wanted to post my finding but missed to reply here. I added the Alteryx root path to Path System Variables on the server before I posted this question here.

 

The problem I think are the warnings in the 2nd workflow. Because, if I run the 1st or 2nd workflow individually through the command line, it works fine. But when I call the 2nd workflow problems arise. The warning error code created by the command line is sent back to 1st workflow which is still open in designer or gallery waiting for 2nd one to complete does not know how to read that error code from the command line of 2nd workflow. And hence it fails and throws that error.

Basically, the warnings from 2nd workflow is considered as an error and hence the 1st workflow fails at end even though the 2nd workflow executed completely and has warnings.

 

There is no way I found on the community to ignore/bypass such warnings. Hence this method won't work for me.

ntobon
Alteryx
Alteryx

@bhanu5 

 

This is expected behavior. Any return code other than "0" will return an error with events or the Run Command tool.

 

Suppose that you have a Main workflow that runs Two Events. When:

1. After Run Without Errors: Run Workflow X using AlteryxEngineCmd.exe
2. After Run With Errors: Run Workflow Y using AlteryxEngineCmd.exe

 

Help doc explaining return codes in AlteryxEngineCmd.exe: https://help.alteryx.com/20193/designer/run-workflows-command-line

 

Values returned when a Workflows run via command line :
0 - Success
1 - Warnings Exist
2 - Errors Exist

 

- When you run Main workflow, Workflow X runs, but it produces warnings messages (value returned is 1).
- Most programs interpret a return code of anything other than "0" as an error which is why you're having trouble with it. Because it was interpreted as an Error, Workflow Y also runs.
- And Main workflow generates an error:
Designer x64 The Designer x64 reported: Error running Event #2: The external program "C:\Program Files\Alteryx\bin\AlteryxEngineCmd.exe" returned an error code: 2: The system could not find the environment option that was entered. (203)

 

WORKAROUNDS:

 

1. Fix whatever warnings are in the workflow for the program to return a "0" status.

 

2. Change the order of execution of the events. Move Up "After Run With Errors: Run Workflow Y using AlteryxEngineCmd.exe" to the Top and then "After Run Without Errors: Run Workflow X using AlteryxEngineCmd.exe"

 

3. There is a way to return a different status code via a batch script. The batch file would have to be called directly:

 

AlteryxEngineCmd.exe "C:\Temp\Test_Warning.yxmd"
if %ERRORLEVEL% == 2 (
exit /b 2
)
if %ERRORLEVEL% == 1 (
exit /b 0
)
else (
exit /b 0
)


This will force the batch script to return 0 if there's an error level of 1, still return an error if there is an error in the workflow, or exit with a 0 otherwise (if no warnings or errors). This is honestly probably not the best way to handle it, but this is an easy method people have setup when people have wanted to run additional workflows in events, as warnings would return "1" and cause an "error" in Designer since Designer sees any event that returns anything other than a "0" an error.

My recommendation is to try workaround 2. Please test it and let me know if it works.

 

bhanu5
7 - Meteor

Your 3rd option might help in what I am trying to achieve but I had already changed the whole process by converting subsequent workflows into macros and used detour tool.

 

Anyways your workaround posted above will be helpful to anyone trying to use command line events. I appreciate the workaround solutions.

ntobon
Alteryx
Alteryx

@bhanu5 could you please mark this post as Solved?