Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Date Interface default?

timothycoxon
7 - Meteor

So I've got a workflow that is designed to run either manually or on a schedule. 

In said workflow I have a macro that uses a "date interface" to select a date.

The idea is that when the workflow runs as a scheduled task it would default to today or if it was run manually then you would be able to select which date you would run the workflow on.

 

Problem I am facing is that it seems to retain the last selection made in the interface.

 

Is there a system variable that is set when a workflow is run on a schedule? Is it possible to set the date interface to default to today?

 

Any help much appreciated.

Tim

10 REPLIES 10
AdamR_AYX
Alteryx Alumni (Retired)

Could you have the macro set up with a arbitrary default. Say 2000-01-01 then have the action inside the macro check what date has been passed in. If it is the arbitrary default replace it with today's date otherwise assume the user has chosen a different date and use that?

Adam Riley
https://www.linkedin.com/in/adriley/
jwalder
10 - Fireball

@AdamR_AYX's suggestion should work. Just make the Action be "Update Value with Formula" and use something like:

if ([#1]='2001-01-01') then DateTimeToday() else [#1] endif

 

 

timothycoxon
7 - Meteor

I do have a default setup so that there is a field for the date interface to work on. 

 

I incorrectly assumed that without direct interaction from a user, i.e. during a scheduled run, that the date interface would default to the current day. Unfortunately it seems that it remembers the last interaction and just goes with that.

 

I was hoping that there was a system variable that I could check against that could tell if a workflow run was manually executed or running via schedule.

 

if [scheduledRun] then [date] = datetimenow() else [date] = [#1] endif

 

Will post the macro when I get into work ;)

jwalder
10 - Fireball

@timothycoxon Presumably you are scheduling a workflow which utilizes the macro yes? If so simply use the default date (something like above or '1970-01-01') for the value in the workflow you are scheduling and have the formula in the action look for that date as being the date when scheduled. (e.g. if ([#1] == '1970-01-01') then datetimenow() else [#1] endif) The macro would only "ask" for a date if it is executed as an "app". If someone adds the macro to their workflow, then it will start with the default date you specified on the date picker within the macro, but yes, if they then select another date, the macro will get that date. If they then save the workflow, it is the date the macro will get until someone changes it again. The idea is to schedule with the the "default" date selected and that the default is a value no one would ever select if running manually.

AdamR_AYX
Alteryx Alumni (Retired)

The engine constant [Engine.GuiInteraction] might do what you want. It should be true if the workflow is being run in designer, false if it is being run via command line or scheduler.

Adam Riley
https://www.linkedin.com/in/adriley/
timothycoxon
7 - Meteor

Will do a little testing on the gui interaction thingy... sounds like exactly what I am after :)

timothycoxon
7 - Meteor

 

Perfect!!

 

Did some testing this morning and it works perfectly. Simple filter on the constant lets me redirect via the date interface if I am running manually or via a formula if I am running via schedule.

 

Exactly what I needed!

Shiv1
5 - Atom
Hi Timothy, I am looking to do something similar. Could you please explain more in detail and provide a screenshot if you can? Thanks
timothycoxon
7 - Meteor

Screenshot 2018-11-29 at 09.12.48.png

This is a quick screenshot of it in an actual process we have running on a regular basis.

 

The macro you can see on the right is the macro mentioned in the post, the interface on the left is the macros interface.

 

The idea basically is that when the process runs on a schedule it defaults to yesterday rather than the last saved date. Or if you manually run the process you are able choose which date you want to use.

Labels