Sunday, June 14, 2020

Three ways to enable / disable a tool container in an Analytic App

On Friday I posted on Twitter how I found the configuration of how a tool container should behave a bit counter intuative. 

When connecting a radio button or check box to a tool container with an action tool, the fixed behaviour is to disable the tool container!

Often when I create analytic apps I want there to be an optional section of the workflow that a user can chose to run or not. Examples would be to save the output file, create a Tableau workbook, select a different API end point etc.

So this blog goes through my initial approach and then two alternatives suggested by Nicole Johnson (@The_Real_NJ) and Chris Lewis (@4loveofAlteryx).

Dummy radio button method - my approach

To account for this behaviour the way I usually set it up is to have a second radio button on the canvas. I'll call this a dummy radio button as it doesn't connect to anything. However it does appear in the user interface of the analytic app.

The advantage of doing it this way, is when selecting the radio button 'Enable the container' it forces the other radio button to not be selected, therefore it doesn't disable the container. And voila it gives the user an option to enable / disable (or should I say disable / enable!) a part of the workflow.

However, the reason for writing a blog post is I wanted to share two additional ways to control the behaviour of a tool container via radio buttons / check buttons which actually follow the desired logic I would have expected in my approach.

Conditional method - Nicole's approach

So the method Nicole suggested is to use a Condition tool.

The way this is configured on the canvas means you can have a single check box in the analytic app interface, where ticking the box enables the tool container and unchecking disables the tool container

Then you need to set up the condition tool as follows:

Here you just set the input connection from the Check box [#1], which when the check box is ticked will be true and when unselected the result of the condition is false. Then after the condition tool you add an action tool after the T(rue) and F(alse) outputs.

It is here where I think the set up then makes sense to the user as you have the option to set the behaviour of the action to to either Enable or Disable the connected container. 

Set up of the action tool after the true condition

Set up of the action tool after the false condition

Update formula method - Chris Lewis' approach

The method Chris suggested was to use the "Update Value with Formula" option.

To be honest when exploring how to do this I didn't really know how to set this one up. But looking into the way Alteryx set up the example Action tool workflow (right click on a tool and select 'Open Example'), it turns out this how they do it!

How to open an example workflow

Within the Action Tool example is a tool container showing how Alteryx set up the configuration to enable/disable tool containers.

So looking at the configuration in the example I was able to discover that you can update the value of the Disabled from False (i.e. the container is enabled) to True (to disable the container), but using a simple IIF statement: IFF([#1], "False", "True").

Like the method suggested by Nicole this approach also follows my expected logic on how to control the container. 

The benefit of this approach is it required fewer tools on the canvas, which to me is a benefit as I typically move all my interface tools to the top of the workflow and use wireless connections, however some may find the syntax of the IIF statement a bit confusing as the [#1] evaluates to true when the radio button / check box is selected (turned on) and false when deselected (turned off). Whereas using the condition tool by incorporating two distinct actions makes it clear what happens when it's selected / deselected.

By showing three methods for controlling the behaviour, hopefully you find a method that works for you and remember to consider review-ability for other users to know what the workflow does.

No comments:

Post a Comment