Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

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

Run set of code based on checkbox

taranoberoi
7 - Meteor

Hi All- I have 2 workfloes which take input from User one in the form of text box and other as a file input. Now I want that there should be checkbox based on which one set of code should run. Like if user selected checkbox then set of code 1 should be activated(which mean textbox input) and code 2 should be disbaled(file input).

 

 

 

Capture.PNG

Kindly help with this. any example would be really helpful.

 

Thanks

18 REPLIES 18
NicoleJohnson
ACE Emeritus
ACE Emeritus
You could put each set of code into it's own Container Box, which can be enabled/disabled, and then use the results of the checkbox to configure the action tool to change the enabled/disabled status in both Container Boxes depending on which one should be running.

If you'd like some more direction/detail on this method, please let me know :)

Cheers!
NJ
taranoberoi
7 - Meteor

Thanks for the help. I tried using containers with condition and tis not working so what i did you can see below too that if condition is true then disable the container 33 and if condition is false then enable container32.

 

In condition expression i have stated [#1] but it gives me error disabled containers may not contain interface tools. 

 

Since I am new to alteryx so need your help. Really appreciate it.

 

 

Capture2.PNGCapture1.PNG

Claje
14 - Magnetar

Hi,

So the particular issue here is that the File Browse and Action tools cannot be inside of the tool containers.  If you pull them out, while leaving your Input Data and Output Data tools inside the Container that should resolve the error message.

 

Additionally, if these are truly mutually exclusive, your solution will work, but I recommend using two Radio Buttons instead.  I've attached some screenshots of how to configure this, but the benefit of this option is that you can leverage the Interface Designer to make it so that when each Radio Button is selected Alteryx will not only disable the tool container, but will also hide that specific prompt.

 

ExampleWorkflow.pngRadio Button ConfigurationRadio Button Configuration

 

Interface Designer - Make sure to nest the File Browse/Text box under their respective buttonInterface Designer - Make sure to nest the File Browse/Text box under their respective button

 

Example of what the app looks likeExample of what the app looks like

 

Hope this helps!

Claje
14 - Magnetar

Hi,

So it looks like the issue here is that the File Browse, Text Input, and Action tools have to be outside of the tool containers.  If you move them out the error should be resolved.

 

However, I'm guessing you're looking to have the interface questions show/hide based on the check box?  If this is the case, I would recommend using Radio Buttons instead.  I've got some screenshots below which should give a decent example of how to implement this.

 

ExampleWorkflow.pngRadio Button ConfigurationRadio Button ConfigurationInterface Designer- make sure to nest each input option below its respective radio buttonInterface Designer- make sure to nest each input option below its respective radio buttonExample image of the final appExample image of the final app

 

Hope this helps!

taranoberoi
7 - Meteor

Thank you and I tried the way you mentioned. Although It serves the purpose of giving selection process but while writing it to final destination it fails. I am sending you my workflow hope u might be able to find something which I am missing but the way u mentioned that helped me selecting one option at interface level. Lets say if I selected Text box and will process it, will give error. and when i give filename and then select text box it will run fine. Which means it need inputs for both the options irrespective to if one is disabled.

 

If you want u can change ur output files although i m sending as an attachments

KaneG
Alteryx Alumni (Retired)

tl;dr: Take out your condition tools and attach Q-Q, as when a radio button is false, nothing changes in the workflow

 

The problem you have is that you have one connection on each of the containers and both containers are enabled as default.

 

Although, you should be able to set it up with minimal connections like this, it offers the opportunity for error. Go through each use case:

  • Option 1 is True.
    • This infers that Option 2 Radio Button will be False
    • The condition will only output through the False side
    • Hence nothing happens to the Condition 2 side of things and both Containers stay Active.
  • Same thing happens (but in Reverse) for Option 2 being True.

There are a couple of ways out of this. 

  • The way that exposes the though process, has an action coming off both of the Condition outputs and use formulas to update the container.
  • However, the radio button returns a Boolean response and so connect that to an action tool and then the Container.

Kane

taranoberoi
7 - Meteor

if You dont mind Could you please share an example.

 

Regards

 

Taran

Claje
14 - Magnetar

Hi,

I've attached an updated example - all I did was swap the action tools to update off of the "false" condition, and changed it to disable the container.  This is probably the easiest way to set your workflow up for ease of editing as well as ease of use in the app.

If this still gives you errors let me know!

taranoberoi
7 - Meteor

I tried using this but it gives error on Option1 . Screenshot shown below.Capture.PNG

Labels
Top Solution Authors