Dynamic Dropdowns

Hello!

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?

Thanks,
Nolan

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’

Hi Matthew, thank you for the response!

I have created the option set and got that to display correctly in my dropdown and in my RG. The RG still groups all meal entries by their assigned meal type (breakfast/lunch/dinner, etc.), but I don’t understand how to do this part of your response:

“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’”

Once the meal entry is saved, I am running a workflow to assign the attribute sort ID to the corresponding field in the ‘Meal Entry’ data type. I am assigning the sort ID correctly and it is showing up properly in the app data. But I still can’t get the RG to sort the grouped meal entries based on this sort ID. What is the process to sorting within the RG editor?

put a field on the data type that is called ‘sort number’ and make it of type number. Then when you save or update the data type you add the appropriate value to the sort number field based on which option the meal type is.

Thank you!

Once the meal entry is saved, I am running a workflow to assign the attribute sort number to the corresponding field in the ‘Meal Entry’ data type. The sort number is showing up in the app data. But I still can’t get the RG to sort the grouped meal entries based on this sort number (descending yes/no generates the same results at the moment). Below is a screenshot of my workflow. What is the process to sorting within the RG editor?

Can’t use grouped by operator after…if you need to sort a grouping you need to sort after group by operaror

Thank you, I got it to sort (well, kind of). Shown below is my RG instruction. When I create a meal entry, it sorts lunch/dinner properly, but sorts everything else randomly (picture taken from preview below). It doesn’t matter what order I add them and the “Sort Number’s Meal Sort Number” is a custom state as this is the only way the RG will display the entries that I created. If I sort it as shown in picture 3, the RG preview is blank. Apologies for all of the questions, but I really appreciate your help!

when using group by you can not sort by a field on the data type used for the grouping, you can only sort by an aggregator from the grouping.

Why are you using the group by anyway? It seems unnecessary.

I am using grouped by so that it displays by meal type (breakfast, lunch, etc.). These groupings weren’t displayed correctly when I was not using the grouped by in the large RH. Should this be changed as well? Again, thank you for all of your help.

are you trying to create an RG that has a cell of Breakfast with multiple breakfast items in the same cell and the same concept for each other meal type? In your example you show just one item per meal type, so Dinner is only showing Ground Beef. If you are only showing one item per meal type you do not need group by.

Yes that’s correct, I am trying to group the inputs with the same meal type. It is only showing one entry in the screenshot as that is what I used for an example. But there could be unlimited entries under each meal type. And then I would like to sort the meal types by logical order that you would eat them during the day (ie. Breakfast, Lunch, Dinner, etc.). That’s step 1.

Step 2 is creating dynamic meal types. So that once the user creates an entry for “Breakfast”, the next time the user goes to creat a meal entry, the options will then read “Breakfast” (so they can add to this meal) and “Breakfast 2” (in case the user has a second breakfast).

I would suggest then that on the meal type you put a field that is of type number and use that to sort by…your meal types will be basically grouped and sorted.

Thank you Matthew,

That’s what I have, or so I think… In the images below I show the RG display process and the field type that I have. It’s still not displaying in the correct order and I don’t understand why. The Meal Type Sort Number is created for each meal entry and sorted from the group. I have a RG inside a RG. The only other thing I can think of trying is creating a third RG. One that generates the entries, one that generates the groups and then one that sorts the groups. Would this be the right way of doing it or am I missing something simple with the RGs that I have setup?


Remove the unique elements and the grouped by and the sorted by operators. Make your type of content Entry: data source is do a search for entry and sort by is sort field.

This topic was automatically closed after 70 days. New replies are no longer allowed.