Can I populate multiple EnumList values using pre-existing data?

Hi,
If I have an EnumList with multiple values, is it possible to automatically select more than 1 value in the list based on existing data in other tables?

Appreciate your response on this. Thanks!

Solved Solved
0 6 649
1 ACCEPTED SOLUTION

Oh, you have multiple posts on the same subject.

Initial value expression:

LIST()
+ IFS(condition1, LIST(preselect1))
+ IFS(condition2, LIST(preselect2))
...
+ IFS(conditionN, LIST(preselectN))

For instance:

LIST()
+ IFS([Needs Red?], LIST("Red"))
+ IFS([Needs Green?], LIST("Green"))

View solution in original post

6 REPLIES 6

Yes. Simply assign the values in List form. For example, if the values I wanted to assign are A, B and C, I would use a LIST() function like this: LIST("A", "B", "C"). A shortcut is: ‘{“A”, “B”, “C”}’

You can do the same with columns: ‘LIST([Column 1], [Column 2], [Column 3])’

Hi, Thanks @WillowMobileSystems

This would only create an EnumList with the options “A”, “B”, “C” etc. isn’t it?

What I want is for either all of the values or some of the values to be automatically ‘preselected’ upon the user entering the form view to enter data so that the user doesn’t have to think and select. The user should be able to change them if they want, but I want the values in the EnumList to be preselected based on other data in the database.

For example, if a certain condition in a particular table is true, I want the “A” value in the EnumList column to be preselected, and if a certain condition in another table is true, I want the “B” value in the EnumList column to be preselected, and if both those conditions are true, I want both “A” and “B” to be preselected automatically in the EnumList column when the user enters the form view.
I tried several ways via the “initial value” in the EnumList, but can’t seem to get the EnumList to preselect several values. Only one value gets preselected. The rest remain unselected even if the conditions to preselect them are fulfilled.

Oh, you have multiple posts on the same subject.

Initial value expression:

LIST()
+ IFS(condition1, LIST(preselect1))
+ IFS(condition2, LIST(preselect2))
...
+ IFS(conditionN, LIST(preselectN))

For instance:

LIST()
+ IFS([Needs Red?], LIST("Red"))
+ IFS([Needs Green?], LIST("Green"))

Dayum! @Steve. It just worked like clockwork! Brilliant.
I actually have no idea how you got this to even work. You’ve opened and closed the parenthesis on LIST at first, and I thought at first whether you’ve made a mistake, but turns out that’s how it actually works. I don’t fully get the logic behind it, but thank you so much for the help.

PS: Sorry for opening up 2 threads on this.

It’s actually not required, it’s just my quirky preference to aide formatting of the expression. You could omit LIST() and just start with the IFS() expressions:

IFS(condition1, LIST(preselect1))
+ IFS(condition2, LIST(preselect2))
...
+ IFS(conditionN, LIST(preselectN))

But that might suggest the first IFS() is somehow different than the others, when really it’s just arbitrarily first. Putting LIST() first also clearly emphasizes that a list is being constructed.

LIST() declares an empty list that will contain the initial values. To that empty list we conditionally add more lists that contain items we want in the initial values list.

See also:

Genius! Thank you so much!

Top Labels in this Space