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
joshuaburkhow
14 - Magnetar
14 - Magnetar

I think what you need is to use the detour tools https://help.alteryx.com/current/designer/detour-tool

joshuaburkhow_0-1597231007839.png

Which you could build logic that goes to left/right actions.

 

Or you can use most interface tools into the 'condition' tool https://help.alteryx.com/current/designer/condition-tool and then based on the condition you can enable/disable a container or containers

 

 

 

 

 

 

Joshua Burkhow - Alteryx Ace | Global Alteryx Architect @PwC | Blogger @ AlterTricks
JustinBabbitt
10 - Fireball

Hi @jensroy 

 

You could probably simplify this using a detour tool. It would look something like the image below. 

 

JustinBabbitt_0-1597231476922.png

Notice that the Text Box tool is hidden, so it won't show up in the interface. 

 

Another way to use the Detour is without a Detour End, which would allow you to pick one set of actions if it is within the timeframe you specify and another action (or inaction) when it is outside of the timeframe. 

 

JustinBabbitt_1-1597231818578.png

I hope this is helpful. 

Justin

jensroy
9 - Comet

I wish I could use the detour tool. But the thing is, I need to disable reading from any data source if datetimenow() is out or range.

The condition tool outputs True or False. The outcome of my Action Tool is also True or False. I just tested with the Condition tool as well.

The True output connects to Tool Container 1, and enables it if the datetimenow() is in range.

The False output connects to Tool Container 2, and enables it if the datetimenow() is out range.

 

Default state is that both tool containers are disabled.

 

Result:

If I run it manually, then I get the desired outcome.

If i run it by schedule (schedule once) then I get the exact same error as before. The date condition is not evaluated at all, so both containers remained disabled.

 

So the server behave differently if a named user is manually pressing run, compared to if the analytical app is ran automatically from the scheduler 😞

jensroy
9 - Comet

I have now added a video that show the issue.

JustinBabbitt
10 - Fireball

That is interesting.

 

One thing to consider when testing/trying out options in the Scheduler is that if you schedule a workflow or app, then make changes to that app, you must Update the workflow OR Delete then reschedule the app using the 'new' version for the app changes to be recognized. 

 

Another thing is you may want to try to save the workflow/app as a package (yxzp file) and schedule the package. If you don't know how to do that, go to Options: Export Workflow. 

 

Thanks, 

 

Justin Babbitt

jensroy
9 - Comet

Yes, puzzles are fun!

 

I tried to upload a new version to the Gallery, but that also had the same behavior. Works with manuel run but not with schedule.

 

I know how to export it, but how can I schedule a yxzp? I would need to open the package, and what I schedule would then be a a workflow or an app?

jensroy
9 - Comet

Here is an interesting update:

 

I just connected my action tool to the text input tool.

 

I wanted to see what the action tool was doing.

 

So in Field1 - Row 1 i wrote the text 2020-01-01 00:00:00

 

Then I used the action tool to "Update value with formula".

 

Running this manually gave me the exact time for the workflow run.

Running this with scheduler changed NOTHING so the output was 2020-01-01 00:00:00. It did not execute the datetimenow() function coming from the Action tool.

JustinBabbitt
10 - Fireball

Hi there - Are you using the Open Debug option in the Interface Designer to test that the Action Tools are configured correctly? 

JustinBabbitt_0-1597239860129.png

 

 

If you set up a second Action Tool with the same logic, and connect it to a Text Input, you can see what is being fed to your intended tools. It looks something like this: 

 

JustinBabbitt_1-1597239909739.png

 

 

jensroy
9 - Comet

Hmm i wont be able to check it this way, because everything works fine if I run it manually. Correct values are getting passed on. It only fails when it is ran from the Gallery and at the same time that an automatic schedule is doing the execution.

 

So my current workaound is that I use the Test tool. The Test tool throws an error if datetime is out of range. The bad part about this, is that the server logs will be clogged with faulty error messages.