Skip to main content
Nintex Community Menu Bar

Providing your Choice Single Control with dynamic options

  • September 26, 2023
  • 6 replies
  • 260 views

Chris_Ben
Nintex Employee
Forum|alt.badge.img+14

Have you ever wanted to make the options displayed in a radio button control (single choice control) dynamic?  For example, we have a menu that changes daily across all three meal types (breakfast, lunch and dinner).  Here’s an example shown in a SharePoint list for today’s menu:

 

In the past, if you wanted to present these dynamically, you’d have to create 3 choice controls (one each for breakfast, lunch and dinner) and hide the ones that weren’t needed via a rule.  Then when the user has made their selection, you also have to know to retrieve the value from the meal type that was selected.  All off this is pretty straightforward but at Nintex, we’re not satisfied with straightfoward - we want it to be fast and easy.

 

So you might have seen @SimonMuntz’s recent post on using data source variables with the single choice control.  That’ s exactly what you’d use for this scenario.

 

First, you have to set up your data source variable.  Here’s the help topic on doing this if you need some assistance.  My example below is to lookup a SharePoint list but remember there are plenty of other systems you can connect to.

 

 

Once that is done, go into your forms designer and add two single choice control fields.

I’ve named the first one “Meal Type” and hardcoded the values to Breakfast, Lunch and Dinner

 

What we want to happen is if the user picks a meal such as breakfast, we want to populate the second choice control with the breakfast options.

 

Now we want to retrieve the meal options associated with the meal type selected and display them in the second choice control.  To do this, we’ll first query the data source we just created by clicking on the external data tab and hitting the “Create data source variable” button.

 

 

We also need to filter the results to only bring back the meal options for the meal type that has been selected:

 

Once this is saved, we can use it in our second choice control which I’ve named “Your choice”.  Instead of hard coding the values (which of course change based on the meal type), you can reference either the array of objects (Meal Selection \ Records collection) or the flattened collection (Meal Selection \ Records \ Meal Option collection).

 

What’s the difference between these two?  Check out @SimonMuntz’s post.  I’ve picked the flattened collection because I don’t have a need to store the meal type ID or any other related data.

 

 

 

Let’s give it a whirl in preview mode.  Too easy! :)

 

Translate

Gavin-Adams
Forum|alt.badge.img+13

Really nice write up Chris.

Love all the screenshots. This is very helpful.

Thanks,

Gavin

Translate

Forum|alt.badge.img
  • Novice
  • December 4, 2024

That’s a great example thanks.  What if I have my sharepoint list with only 3 rows, Breakfast Lunch and Dinner and with multiple values in one row, e.g. pancakes scrambled eggs, fruit and yoghurt in one Breakfast Sharepoint item? . 

Can i use a sharepoint multiline field (or option field or computed ?) to achieve the same result?

For instance we are trying to show available booking options in a choice-multiple form control per work site without duplicating the site Sharepoint items (rows). 

Why do i want this?  because i want to make the site easiesh to use for the list editor.

Translate

Forum|alt.badge.img+2

OK daft question - can this be done using a data TABLE created in the Nintex automation environment, rather than from a SharePoint list or other external connection.

I’ve been trying for a full day and the variable functionality is missing the ability to format it as an array, which then means you cannot create the variable to pull the values into the choice field.

I will be created an online form, so a SharePoint list isn’t an option as everything sits behind a firewall.

Translate

Forum|alt.badge.img
  • Novice
  • February 24, 2025

not daft.  Variables don’t store arrays as you have rightly said, but the lookups to data table return arrays just like Sharepoint list.  In other words, don’t use variables, just have the options in the choice-single control.  You can combine with formulas, e.g. in this case i have dropdown options for CARD vs DIGITAL building access.  Of course you can’t have ‘lost card’ for Digital , so i keep the options in the data table rather than hard code:

ifelse(contains(toupper([Form].[Access type]), "CARD"),
         [Table data].[Action required options card only].[Rows],
         [Table data].[Action required options card and digital].[Rows])

 

david (rookie)

Translate

Chris_Ben
Nintex Employee
Forum|alt.badge.img+14
  • Nintex Employee
  • February 25, 2025

Hi Robert, you can definitely use data stored in a Nintex table in your choice fields.  Here’s another post that explains more about tables but also has an example where the table data is used in a choice field.

 

 

Translate

Forum|alt.badge.img+2

not daft.  Variables don’t store arrays as you have rightly said, but the lookups to data table return arrays just like Sharepoint list.  In other words, don’t use variables, just have the options in the choice-single control.  You can combine with formulas, e.g. in this case i have dropdown options for CARD vs DIGITAL building access.  Of course you can’t have ‘lost card’ for Digital , so i keep the options in the data table rather than hard code:

ifelse(contains(toupper([Form].[Access type]), "CARD"),
         [Table data].[Action required options card only].[Rows],
         [Table data].[Action required options card and digital].[Rows])

 

david (rookie)

You are…..

 

Awesome - than you works a treat

Translate