Free Trial

Dev Space

Customize and extend the power of Alteryx with SDKs, APIs, custom tools, and more.
SOLVED

A Macro that checks if a file is locked

mix_pix
10 - Fireball

Hi,

 

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).

 

lock check macro.png

 

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. :-)

 

-Mike

2 REPLIES 2
mix_pix
10 - Fireball

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.

 

macro.png

JBarry2017
6 - Meteoroid

Has anyone ran into issues with this macro and received 'The score output "" was not a valid output' error?  I've modified the initial macro inputs to point towards files on my PC, and when running the initial macro standalone, it runs fine.  However, the above error is received when the initial macro is within the final macro.

 

JBarry2017_0-1598448598647.png