Is there a way in Alteryx to check if a file is already opened before downloading it?
I'm trying to check if a file is already opened before opening it in Alteryx so that I can avoid errors with the dynamic input tool. I imagine the setup looking something like a Try, Except block in Python.
I've already tried using the Run Command tool for this but am unable to because the PowerShell function below is in a Constrained Language Mode for me.
PowerShell Function: [System.IO.File]::Open("network\folder\test.xlsx", "Open", "ReadWrite", "None")
Constrained Language Mode Definition: PowerShell Constrained Language Mode is a security feature designed to limit the capabilities of PowerShell to reduce the risk of malicious activities. It restricts access to certain language elements and APIs that could be exploited by attackers, while still allowing administrators to perform essential tasks.
If there's no way in Alteryx to do this I'll have to see if IT will allow me to run this function.
Two thoughts come to mind; one of which you've kind of already defeated 😂
I do use Run-Command to copy/robocopy files before bringing them into my workflow when there's a risk someone might have it open. This sidesteps that problem by taking a copy to use in the workflow, then dumping that copy at the end of the process. Sounds like your PowerShell component is not going to allow for this though...
You also mentioned Python. Could you consider using the Python tool in your workflow to perform that Try>Except method and based on the findings output a value that drives some sort of notification if blocked. And of course, running the workflow if not blocked?
Not a direct answer but trying to engage in creative problem solving with you. Hope that sparks some ideas. I'm sure others will chime in here as well. -Jay
Thanks for the reply! Unfortunately you're right about RoboCopy not working. It's actually not due to the Constrained Language Mode though. It's due to the fact that when users at my company open a file the option to read it by another user is not allowed. Apparently, RoboCopy can work if the file handle has the Read share mode but that's not the case.
I did think about using Python but my Python tool hasn't worked in a couple years...Every time I open it I get the below screenshot that just hangs there. It's incredibly frustrating and worth a different thread if that turns out to be the only solution.
For context, I'm running Alteryx Designer version 2022.1.1.42725. I haven't seen any issues with the Python tool on the Alteryx release documents.
Ya, all that tracks. I'm sorry you're experiencing such annoying obstacles.
Regarding python tool: Yes, I would definitely recommend posting a separate thread (or if that doesn't yield any good answers, open a support ticket). That said, your version is getting a wee bit old and is probably beyond support. Any way you can convince your admin's to modernize up a bit? I think, these days even 2023.1 is near the end of support.
This article might be helpful for your case. Sometimes the Python tool takes longer to open Jupyter Notebook because it uses miniconda.
https://www.geeksforgeeks.org/python/check-a-file-is-opened-or-closed-in-python/
It has taken me weeks to get the OneDrive tool downloaded to our server so I can use it in the gallery so I doubt I can request that they update to a newer version. The previous Alteryx admin we had was great but oh well. Thank you anyways. Going to give the article @dreldrel a shot. I've left designer open for hours before and the Python tool still remains in the state that you see in the screenshot I provided so this might be a support ticket.