I have an Alteryx Analytic App which outputs 50 excel files which can be downloaded on server one by one. I want to change it so that just a zip file containing those 50 files can be downloaded on server/gallery. I have seen multiple threads about it, but haven't been able to find a solution.
I have been able to zip the files when running Alteryx Designer locally using Events > After Run Without Errors and calling a powershell script which compresses the files in a location and output a zip folder.
1. But when I publish this to gallery it gives me this error: The external program "powershell.exe" returned an error code: -196608: The system cannot find the file specified. I believe Alteryx server can't find the powershell script because when i publish the workflow i'm unable to attach it using the "Manage workflow assets". How do I make sure it is being published as well?
2. Locally I explicitly tell the script where to find the excel files - how would I have to change the powershell script to work on Server/Gallery?
Current Powershell script:
Compress-Archive -LiteralPath 'D:\...\Staging\...\_externals\1\' -DestinationPath 'D:\...\_externals\final.zip' -Force
Any help is greatly appreciated!
Solved! Go to Solution.
in the "Edit Event" window, you can include static assets in the "Asset(s)" tab so that they are packaged when publishing to Gallery.
FYI though, if your using a static PS script with hardcoded paths, it's likely not going to work since the actual path the server stages the workflow is always a unique hash-like directory. You may need design something within your workflow that dynamically creates the script using the workflow constants [Engine.TempFilePath] and/or [Engine.WorkflowDirectory] to dynamically generate those paths and instead of using an event, use the Run Command tool.
@jrgo Thank you so much for showing me how to add assets when publishing to Gallery. For the 2nd part, I understand it might not be possible without using workflow constants, but I have 50 sets of Table, Layout and Render tools that I want to finish processing before calling the Run Command Tool to zip it all. I have thought about using Block Until Done, but I'm not sure how I will put it all together to run after all Tools have finished processing. Is there a way to tell Alteryx to process Run Command Tool after the rest of the workflow has finished?
Here's a way to integrate some process control that I use often. The Record Count tool always outputs a single data point, but is dependent on the input data so - in connection with the Block tools - it's forced to wait until all the outputs are done before the data is union'd then counted.
@jrgo - Thanks a lot for explaining the Block Until Done usage here. I have a test workflow I'm trying to make this logic work on. It looks like this:
I was able to construct the script in the formula tool correctly, but I'm unable to read the results of formula tool in the Run Command Tool. Could you help me understand how would I do that? As of now, the yxdb file has the result from formula tool. But I don't know how I would call it as a powershell script using Run Command Tool since I wont be able to save it as a ps1 using the Write Source option.
Let me know if there's anything you recommend. Thanks for all your help so far!!
PS: Will the output zipped file will be available using the Write Source of the Run Command (see screenshot above) and be downloadable on server?
Thanks for marking my response as the solution!
In regard to your last question... running a PS script is a bit different than running a batch CMD. Also, the workflow constants will only be useful when used by objects native within Alteryx. i.e., including %temp% in the "Command" field on that Run Command tool simply just passes that to the shell so it'll be interpreted to your system variable, not Alteryx's constant for that tag.
Take a look at this KB article which reviews calling PS in Alteryx. If you're still unable to get it to work and if you're able to, send over a copy of that test workflow and I'll try tinkering around with it and see if I can get it to work.
@jrgo I was able to figure out zipping all temp files created in the %temp% that match a certain wildcard and output the zip file in the %temp% location as well. Thanks a lot for all your support. My final issue (which is why I did all this) is that how would this final zip file then be downloadable on server instead of all the individual files?
Attached is a test workflow which creates the zip files in the %temp% location, the only issue now is how to make this zip file then downloadable when running workflow on server. I am using the last formula tool to get the location of the zip folder that needs to be downloadable on server
hmm... yeah I see the issue there. My guess is that Gallery is not showing it as an option to download because the zip was not natively generated by the Alteryx Engine which doesn't get attributed as a file to show.
I'll tinker around with this and see if there's a round-about way to make it show up and let you know what I'm able to find.
Unfortunately, I'm striking out here. Attached is a copy of what I've added which is intended to grab read the zip file that's in the temp folder as a BLOB and then write it out to the active workspace... essentially doing a copy/paste of a file.
This works when I run it locally on my machine, but when I test in Gallery, it seems as if the zip file within the temp folder is not accessible and get the error below.
I've used this approach (with the Blob tools) before to have a file show up and make available for download in the result screen before so I know the concept works, but not sure why it always returns "Cannot access file". It may also just be something to do with folder permissions on my server, but only have this one environment to test on at the moment so - fingers crossed - maybe it works for you.
If it doesn't, maybe a ticket to support is required to see if they're able to assist or post a new question in community.
Jimmy
@jrgo That worked for me on server!!! It might've been a permissions issue on your end then. Thank you so much. I really appreciate all the help. Now you have 2 solutions on this post - yay! Hope you have a wonderful day.