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.
About a week ago I posted a question about how to best check if a file is locked. I have some workflows that read in a shared yxdb file and sometimes that yxdb is being updated when a workflow attempts to read it, and so the workflow throws an error and skips that input, which results in me having to re-run the workflow once I receive the error email.
The response from @ScottJ gave me the guidance and inspiration I needed to put together a macro that does exactly what I needed. Specifically:
It takes in a file and directory as inputs and checks if that file is currently locked.
If it is locked, it waits X seconds before trying again, until the maximum iterations are reached.
I added some steps to identify if the file and directory actually exist, whether a sheet name is provided (in the case of Excel files), and set it up to handle (as of now) three different types of input (yxdb, Excel and CSV...the most common input files we work with).
I suspect there are ways to make this more robust and handle more use-cases, but since I hadn't seen anything like this out there yet, I figured I'd share it with the community in its current state to both help others who might be facing a similar challenge as well as to see if anyone might have ideas on how to make this macro better. I haven't worked with macros too much (and this was my first exposure to batch files), so I am sure there is a lot I can learn. :-)
My original macro ran into some issues when executed on Alteryx Server, but @patrick_digan was able to help me troubleshoot and update the workflow to ensure smooth and consistent execution whether run locally or on a server. Thanks Patrick!
I've attached the updated macro, which has also been augmented to allow the user to select how long the iterative macro should wait between iterations.