Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

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

assign a constant to multiple workflow. Use command line/ .bat file to assign constants

Dylan777
5 - Atom

I usually configure my input and output directory with a constant

For example:

%my_constant_path%/specific_standard_path/file_name.csv

 

%my_constant_path% is the constant I assign. 

 

For each project, I am using like 10 of this standard workflow. Each project would use a different work directory, so I will have to assign a different value to this constant for each project.  

 

However, I don't want to configure 10 times for 10 workflows for each project. I wonder if I can assign the same value as the constant to all the workflow at once. I am researching on whether I write a script (maybe a .bat file) to assign a value to %my_constant_path% for multiple workflows all at once. These will also potentially help me with another improvement I have in mind.

 

I will try to avoid turning all my workflows into apps because each workflow is quite complicated and will need a lot of work to convert any workflow into an app. 

 

 

10 REPLIES 10
ChrisTX
16 - Nebula
16 - Nebula

Within each workflow, you could paste (overwrite) the XML code to define all 10 of your constants at once. See screenshot.  You may need to set the user option to Display XML.

 

Or you could write a workflow to open each workflow YXMD file and update the XML (text) lines for constants.

 

ChrisTX_0-1594309211223.png

 

Chris

Dylan777
5 - Atom

Hello Chris,

I find your solution very interesting. Glad to know each workflow can be view as an XML code( this is new to me) and the constant can be assigned by overwriting the XML code. 

I especially like your idea of creating 1 workflow to update all the XML files. Can you be a little more specific on how can I accomplish this? 


Thank you

ordinary-but-trying-to-contribute-Dylan

ChrisTX
16 - Nebula
16 - Nebula

You can read in any YXMD file (or any XML or text file) using the Input Tool file format CSV.

Use \n as the delimiter, for new line.

 

ChrisTX_0-1594380264518.png

 

Then use any Alteryx tool to manipulate any line within the file.  Assign record ids, cut out the lines between the text <Constants> and </Constants>.

Then replace those lines with your custom lines for constants.

 

Chris

Dylan777
5 - Atom

Hello Chris,

I have not had a chance to actually finish testing your brilliant solutions yet. 

I am assuming that the spacing is not mattered for the XML code, because all the space are trimmed when inputting into alteryx. 

ChrisTX
16 - Nebula
16 - Nebula

If you're asking about spacing for indentation, no that shouldn't matter.

 

But I would try to keep the rest of the format the same as the original XML:

 

ChrisTX_0-1594395812523.png

 

Dylan777
5 - Atom

I try it. It works!

This is a very innovative and excellent solution! 

The only thing I want to add is make sure to set the field length(7) as a very big number like 9999999. 

jrobiso2
8 - Asteroid

My Canvas area does not have that "XML" option.  Is there some way to enable it?

 

Using version 2020.2.3.27789

ChrisTX
16 - Nebula
16 - Nebula

The checkbox for "Display XML in Properties Window" is under this menu path:

 

Options > User Settings > Edit User Settings > Advanced (tab at the top)

 

Chris

jrobiso2
8 - Asteroid

YAhoo!!!!

 

Strange add-on to the question . . . can I set a User constant to a value of another constant, such as "%Engine.WorkingDirectory%\ExtraFolder" ?

Labels
Top Solution Authors