Alteryx designer Discussions

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

Get the workflow name in a Formula tool

Highlighted
Meteor

Hello,

 

I know the question has been asked in other threads, but they are a bit old and the suggestions are complicated.

In the Designer, I'm trying to output the workflow name to a database as a way to track how the data has been generated. I know there's the constant [Engine.WorkflowDirectory] that I can use in a Formula tool, is there something equivalent to get the workflow's exact name?

 

A solution involving parsing the content of the directory wouldn't work, as I can't ensure there's only one workflow in the directory (e.g. because versioning)

 

Thanks!

Amaury

Highlighted

At present there is no constant for this. 

 

The easiest is probably to add a user constant when you create workflows but this wont be tied to the filename.

 

The only other option I have come up / accross is to read registry to see most recent opened workflow. See http://community.alteryx.com/t5/Data-Sources/how-to-dynamically-store-workflow-name-in-a-variable/m-...

 

Best improvement I have come up with is to read all the recent files and filter by the workflow directory constant. I have attached a macro which will output the filename of the current workflow.

Highlighted
Meteor

Thanks for your answer!

I had seen your solution using the registry, but as far as I understand the registry stores the files that were recently opened, not the ones that were run. So if I have multiple versions of the same workflow open, no way to tell which one created the data...

Highlighted

Yep as far as I know no way to get at it directly at moment.

 

Might be possible to do something with the CReW Runner macro and adjust it to assign a constant to the running flow. (but this is just an idea would need to play to see if possible).

Meteor

Ok, I saw it's actually in the development suggestion list so I voted for it. Thanks for pointing me to the CReW macros, it actually has the solution for another problem I was about to post about :-)

Highlighted
Fireball

This is a problem I came across, I raised the Idea as it would be very useful for the environment in which I work. My current solution is to add it as a new user constant in the Workflow section of the Workflow Configuration.

Highlighted
Meteor

Ok, I finally found an indirect way to do this!

 

1. Create a simple batch file that just outputs an argument to a file (e.g. "echo %1 > file.txt")

2. In the Alteryx workflow, define an event of type "run command", configured as:

- Run Event when: Before run

- Command: the path to the batch file

- Command Arguments: "%Module%" (with the quotes)

Every time the workflows runs, this event will run as first thing and output the module name (=workflow full path) to the text file. It also works if this logic is implemented in a macro (i.e. will output the name of the workflow that launched first, not the macro).

3. In the worfklow, add an input tool to get the "file.txt" back into the workflow, with the workflow name.

 

Note that it would be way simpler if the workflow name was added to the Engine constants, as mentioned elsewhere!

Thanks to folks in this thread who mentioned the workflow name can be used in events: 
http://community.alteryx.com/t5/Setup-Configuration/Log-File-Location-and-Variables/m-p/658#U658

 

 

Highlighted
Creative Director
Creative Director

@Amaury, thanks for supplying the detailed instructions.

 

If anyone is interested in seeing this feature in an upcoming release, please vote here:

http://community.alteryx.com/t5/Alteryx-Product-Ideas/Include-the-Wokflow-Name-as-a-default-Constant...

 

To vote on the idea, you click the star. You can also comment on the idea with your use case. This helps our Product Management team to prioritize the feature. 

Tara McCoy
Labels