Dynamic Dropdowns


I am trying to do a couple things with my food app that I can’t seem to get.

  1. Dynamic Dropdown.
    When the user is creating a new meal entry, and are selecting the meal they would like to create/add to, I want the dropdown list to show the set meal titles. For example, once the user selects ‘Lunch’, the next time they click to create a new meal entry, I would like the dropdown to display both ‘Lunch’ and ‘Lunch 2’, showing a second lunch meal option to create.

  2. Non-Alphebetized Repeating Group.
    I have a RG to display the meals for the current day. I have it so it sorts based on Meal Title, but the RG currently displays them in alphabetical order. I would like to have the default display be a set order (ie. displaying ‘Lunch’ ahead of ‘Dinner’). How do I accomplish this? Do I have to create a custom state and sort the RG input based on this state?


This can be achieved in many ways, and you need to think about other meals like Breakfast or Desert, because if you set your app up now to just look at the alphabetical ordering, yes, Lunch can come before Dinner as it naturally does in our daily lives, but Breakfast would not be before Lunch, it would be after Dinner in your RG if you rely on alphabetical sorting, and Desert would come before Dinner, but anybody who has ever dated knows Desert only comes after Dinner.

So, to set that up to make it so your future additions to meals which would like include Breakfast and Desert, you should not rely on the alphabetical ordering and instead rely on a number that you determine as the proper ordering. So Breakfast = 1, Lunch = 2, Dinner =3 and Desert = 4.

To do that you can have an option set for your meal types and an attribute of type number.

Then on the datatype you are using in your RG to display the Meals (I’ll assume your naming convention is logical and you called this data type Meals) you should have a field for the option set that should be called Option-Meal-Types (ie: the breakfast with attribute number of 1). But you will also need a field to sort by, as you can not sort by fields that are option sets or related data types, so this second field to add would be ‘sort number’ and when ever you are running workflows to create/modify, make sure you set the ‘sort number’ to the meal types number attribute (ie: if it is lunch this field will populate as 2. And do not attempt to set Lunch as 1 and Dinner as 2 for now just because your app only at this stage has these two, you should follow the outline I provided where Lunch is 2 and Dinner is 3, so that if you add Breakfast you do not need to update all existing data, since 2 comes before 3 anyway and if there are no 1s’ it doesn’t matter.

So your RG will have the sort by set to ‘sort number’