Let's assume that my files of interest will not always be located in the same directory, but I know the 2 potential locations. Problem is, one directory will be visible to alteryx, but the other not (let's say the same workflow may be run in different environments, where one of the two paths won't exist, but you want it to work in both environments without having different versions of the workflow). I'm trying to avoid a solution like "Just use 2 directory/input tools pointing to each path", as one of the 2 tools by nature will always error with the msg "Invalid directory X, the system cannot find the path specified" or "File not found" (depending on which type of tool is used), and potentially break all downstream processing.
Is there a more elegant/dynamic way of having a sort of input looking first in X directory for all files, and if no such directory is found, look in Y directory, in a way that the workflow does not break downstream due to a "non existent" path?
Thanks in advance.
Solved! Go to Solution.
I think this would use two Directory Tools → Union Tool to combine the contents → Filter to the file name → and Sample 1 result. The top result will be prioritized so you could sort by the folder location first (or be judicious when unioning) → Dynamic Input (with the fullpath being updated)
I think this should work!
In the case of just using directory tools this does seem to work @PhilipMannering , however if I try to feed that filepath (along with a specific sheetname) into a dynamic input, it breaks. The exact behavior is a bit strange: My dynamic input does not throw any errors whatsoever, but it outputs nothing. Attaching two relevant screenshots
Any other ideas on this?
Hi @AkisM
What do you think about this idea?
1)As you have different folders for different users, and each user has his own username, you can get the username of the machine
Include Username in Workflow - Alteryx Community
2)As you know the username of the machine, you can develop the logic to select the right directory for the right username
3)You can pass the right directory to a macro and replace the directory input of the macro.
The workflow is attached.
If the provided answer helped you to solve the problem/was correct, please accept it as a solution :)
Thanks.
@Felipe_Ribeir0 That's a great idea that works as desired for Input and Directory tools. But how would we achieve something similar for outputs?
Say near the end of a long workflow, I have lots of columns/rows of data. Normally one of those columns is the filepath where the data should be written to, so my output is configured to read that column and write data there. But if the "preset" file or path that the output is pointing to does not exist in the first place (which is our example - running in different environment), then even if the column that the output refers to for the fullpath contains the correct path, the output results in an error.
How would you get around this issue to make the output dynamic as well and not give errors of a nonexistent path?
Hi @AkisM
You can use the same logic, the difference is that you need to take the field name from the formula and pass it to the output.
If the provided answer helped you to solve the problem/was correct, please accept it as a solution :)
Thanks.
@Felipe_Ribeir0 Thanks, my mistake was trying to use a nonexistent location in the tool's default settings because I assumed that reading the path from a specific field would fix the issue anyway. I guess the solution is to point to a default file that you know for a fact will exist on both environments so that the tool itself doesn't error, and then it will get the right path from the field anyway. Thanks