Alteryx Designer Desktop Discussions

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

Using [Engine.WorkflowDirectory] inside a macro, to get the location of the macro

YEM
8 - Asteroid

The question is on using the [Engine.WorkflowDirectory] “constant” inside a macro.  I would like it to return the directory of the macro, and not the directory of the workflow that called the macro.  Or, I would like a work-around to accomplish the same thing: The macro needs to know where the end-user put the macro. (because I’m packaging dependencies with it, and relative references are not working).

 

To illustrate the issue, I have created a simplified example.

Download the YXZP, double click to extract / open.

Right click on the marco, select "Open Macro:...". 

Run the macro once.  Inspect the output.

The output is the location of the Macro.  This is what I want!  So far so good!

YEM_0-1587392981149.png

 

Close the macro.  Now run the yxmd file “Call Example Macro.yxmd”.  Inspect the output coming out of the S anchor:

YEM_1-1587392981154.png

 

 

The path shown is the path of the parent workflow calling the macro, not the path of the macro itself.

 

I’m developing a larger application that depends on knowing where the end user has put the macro.

 

So finally, my question… How do we develop a macro in which we can reference the macros location inside the macro itself?

 

If you’re wondering why I need this, it is a much larger conversation.  So, I just wanted to post a boiled down example and see where the conversation goes.

Thanks for your support!

2 REPLIES 2
seven
12 - Quasar

Hi @YEM 

 

here is a workaround to get the location of the macro.

 

In Windows, the period (.) signifies the current directory. What is a period in Windows? 

We can use the period in the Directory tool to pull a list of files in the current directory.

 

image.png

 

Alteryx will return the full path of the current directory too.

image.png

 

Then it is trivial to build a macro to output the information.

image.png

 

We can see the Directory output side by side with the [Engine.WorkflowDirectory]. [Engine.WorkflowDirectory] can be removed in production.

 

image.png

 

The macro is lightweight and can be placed into any of your macros.

 

I added the macro, the test workflow, and a packaged workflow too.

YEM
8 - Asteroid

Exactly what I needed.  Thanks!

Labels