Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Server Discussions

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

How to disable a tool container based on DateTime - Scheduled workflow

jensroy
9 - Comet

Hello!

 

I am facing a weird issue here. I have a workflow that i have saved on the server. If I run it manually from the server Gallery then it works as intended. But the same job "fails" when I run it on a schedule.

workflow issue - datetime.png

What I want is the workflow to either go through container 1 or container 2. Below is the formula I use in the action tools but the true/false is opposite. So if datetimenow is between 08:00 and 23:59 then the top container is enabled and the bottom one is disabled. If the date is not in that range, then the top container is disabled and the bottom on is enabled.

 

 

 

if DateTimeNow() >= ToDateTime(left(datetimenow(),10)+" 08:00:00")
and DateTimeNow() <= ToDateTime(left(datetimenow(),10)+" 23:59:59")
then "True" else "False" endif

 

 

 

And this date check only works if I run it manually from the gallery. As you can see from the screenshots, the manual run outputs only 1 record, while the scheduled one outputs 2 records.

 

The reason I need this to work is that we are not allowed to run ETL jobs outside the time range, but Alteryx server cannot schedule "run every hour, every day, but only between 08:00 and 23:59". So I want to schedule the workflow to run every hour, but if the datetime is out of range, then the whole workflow is disable.

 

Here is a video of the workflow behaviour:

11 REPLIES 11
JustinBabbitt
Alteryx
Alteryx

When you run an analytic app, or macro that uses an Action Tool, you have to run it as an App for the Action tool to work either by Debug or "Run as Analytic App" (wand). If you run it as a workflow when testing, it will take whatever values you have in the tools to work, which can create false positive testing results locally but could explain why they aren't working in the gallery/server environment. 

Justin Babbitt
David-Carnes
12 - Quasar

I have solved this problem by putting the main logic into a Batch macro then using the Control Parameter to Delete Tool from Workflow the Container that has the stuff I don't want to run.  Here's my real life example.


(The use case is sending a REST API call to SendGrid in which I don't know if there will be attachments to said email)

 Inside the supportng macro that is creating the JSON for the attachments part.   I need something to come out the macro regardless of input.

The Control Parameter takes a Bool and deletes one or the other Container.  Here, a True deletes the bottom Container and a False, the top one.

David-Carnes_0-1597257036387.png

 

Inside the SendGrid macro that the users interact with. In this case I count the incoming records then convert the interger into a Bool by changing the datatype.  A zero translates into False and any number above that becomes True.

David-Carnes_1-1597257470526.png

 

 

Hope this helps!

Best,

David