We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Server Discussions

Find answers, ask questions, and share expertise about Alteryx Server.

Powershell script to trigger gallery workflows

csh8428
11 - Bolide

Does anyone have a powershell script that can trigger a workflow to run from the gallery? I'm a server admin and gallery curator. 

 

I'm not familiar with powershell scripting and I already tried Gemini to generate the script, but no dice. I've triggered gallery workflows to run using the api tools within workflows, but never done it using a powershell script on the server where the gallery resides.

 

Problem I'm trying to solve:

We have a series of workflows that need to be triggered in sequential order AND each successive workflow can only be run when the previous workflow has been completed. My approach was to add a "run on no errors" event at the end of each workflow that triggers a powershell script that triggers the next workflow via gallery api. 

 

 

4 REPLIES 4
abacon
12 - Quasar

@csh8428 I haven't done what you are trying to do with PowerShell but you can use the API call to do what you are trying to do. If it needs to be sequential, have each workflow have a server API tool at the end that calls the next one. Set each workflow to cancel on error and you will have the same functionality without the PowerShell script.

 

Bacon

csh8428
11 - Bolide

@abacon Great idea! I had tried a similar approach in a "master" workflow where each API call was run in a control container controlled by the previous api call, but that didn't work. Your idea basically turns it into a daisy chain. Thanks again. For other reasons I would still want to do this via powershell, so I'm going to leave the post open for now. If nobody else answers my post to this via powershell I will mark yours as the solution.

abacon
12 - Quasar

@csh8428 I totally understand!

 

Here is how to trigger it using command line, maybe you translate this to a powershell command. I believe this is the same idea, just slightly different language.

 

https://help.alteryx.com/current/en/designer/workflows/run-workflows-via-command-line.html#run-workf...

 

Bacon

KGT
13 - Pulsar

The Command Line approach referenced above is different to the Gallery API and although you could use that, it would be on the server environment (for it to work) and it would be outside of the gallery, as you would be calling actual files. This has many issues regarding logging etc, as you're taking the process outside of Gallery.

 

The main aspect is handling the auth, then handling the responses in order.

 

I highly recommend trying the gallery API at the end of the workflows to add the next workflow as a job (depends who's building them etc, but in this situation, you would create a batch macro where they select the next workflow to run and it's implemented in a way that it will only get data if the workflow has completed (simple append/filter or something).

 

Take a look at this post for some ideas of using the API in Powershell: https://community.alteryx.com/t5/Alteryx-Server-Discussions/Migrate-Workflows-via-Admin-API-Powershe...