This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
It sounds like you will have to use a cmd script to check whether or not the connection to the network drive is live as well as a detour tool that points to the local location if the network location is not available.
This is a simple batch script that checks to see if the M Drive is connected. You could swap this out with the name of your drive that you have connected. I don't have experience passing values from a command prompt back into Alteryx, but maybe someone else can chime in.
I got the command prompt to work so that it indicates if the connection is active, I am just not sure where to go from there.
I need some logic that says if the connection is active to save to shared drive output, otherwise save to desktop. But I really have no idea how to properly configure this tool, so any further suggestions would be greatly appreciated!
I modified the script a little bit and added in either echo offline>connection.txt or echo online>connection.txt based on the result. That means that the script will write a text file with either "offline" or "online" in it depending on the outcome. Then in the run command tool in Alteryx, you specify to run the command in the Run External Program box. After that, you select the text file offline/online output in the Read Results box down at the bottom. That means that when the batch file is run and we get the output, the run command tool in Alteryx will have either "offline" or "online" coming out of it. My suggestion would then be to use a formula tool to do something like this:
So basically you could use a simple true false statement to say if the output file says "offline" then use the desktop path, and if it says "online", use the network path. Then in your output tool, you can check the box to "Take File/Table Name From Field", Change Entire File Path, and then use the output we get from this command prompt.
You could output the file locally and then MOVE it to the shared drive. If you are unable to reach the shared drive then it will fail and you will still have the local copy. If it can reach the shared drive, then it will no longer be on the local drive when the MOVE completes. If you are looking for non-command ways to do file system activities, we built a tool for that called "File System Tool", see here: https://community.alteryx.com/t5/Alteryx-Knowledge-Base/Partner-Tools/ta-p/123297
There are many ways to solve this problem. As others have suggested, you can create a batch file and run it in the command tool or output to a local drive and try to move it to the network drive. Those will certainly work, but I prefer to use 100% Alteryx solutions when possible.
You can use the FileExists() function in a formula tool to test if the network directory exists. Something like "FileExists('\\network_drive\output_location')". This will output a true or false (aka boolean). You will use the boolean output of this formula as the input to a standard macro you'll create. Inside that macro, you'll setup a detour based on the network directory existing or not.