Create list from enumlist column

I have a table named "users" which has a column named "Group" which is set as enumlist with a base type of ref. I have another table named "messages" with a column named "group" which is a ref to the users table. I would like to populate the "messages" table column "group" with a list of only the values in the "users" table column "group". I have tried this code

select(users[group], IN([Group], [_Thisrow].[Group]))

but I get an error of Paramter 2 of function IN is of the wrong type. What am I missing?

0 11 145
11 REPLIES 11

Aurelien
Google Developer Expert
Google Developer Expert

Hi @Tragertt 

This is because EnumList is considered as a text, not a list.

Can you try:

 

select(users[group], IN([Group], SPLIT([_Thisrow].[Group], " , ")))

 

Also, to avoid any confusion:


@Tragertt wrote:

with a column named "group" which is a ref to the users table


I recommend you name your columns according to the table they refer to. In this case, you may want to consider renaming "group" into "user"

 

Here is where I am at now

Tragertt_0-1671473915917.png

I have tried changing all the types but I think the problem is the new Database feature in appsheet. I have noticed that if in appsheet it is set to enumlist but in the database it is set to text it conflicts with it.

Maybe, I'm actually not experienced with AppSheet database today as I avoid using it while it is unstable. 

From my understanding, there is a strong will to establish a consistency between AppSheet Database and AppSheet app editor at the moment, which is for the best but currently generating misunderstanding for beginners.

Can you try with a Google Sheets or Microsoft Excel datasource instead ? It is more flexible.

I just switched it to sheets, I think its more flexible. I will let you know. 

Aurelien
Google Developer Expert
Google Developer Expert

I read again your initial message, I think I misunderstood your request.

in your table "message", do you select the user ?

If so, I guess you are trying to populate the groups of the current user. Correct ? 

If so, can you try, simply:

[User].[User group]

This is called a dereference expression.

More information here:

Dereference expressions - AppSheet Help

 

I am making a messaging app. You add the groups on the users table and then on the messages form I want whatever group is listed in users group column to be listed as an option to be able to send to. For example I have a person with group Admin, Principals and Public info. I want the message form to see those groups and show it as a list to click. So a person that wants to send out a message will choose principals group and any user that has that group listed principals will get the message.

Aurelien
Google Developer Expert
Google Developer Expert

It makes sense now, thank you for your further explanations about context.

Here is my suggestion:

1) create a table GROUP, column key, type Text ==> will hold your groups

2) table USER, column Group ==> type enumList, base type Ref, source table GROUP

3) table MESSAGE, column Group ==> Type EnumList, base type Ref, source table GROUP

That should do the job for your purpose, at least for the first step.

That works but it is showing only the groups that have already been assigned to a user. For example on the groups table I have Administration, public info and Principals. I do enumlist with ref on the other tables but it doesnt show all the gorups in the groups table. It shows only the group that has been assigned to a user, in this example it only shows Public info and not the other 2 groups. Ive done this thing many times before and it doesnt seem to be working...

the field is setup like 

Tragertt_0-1671486717770.png

And when I add a user and try to add a group it looks like this

Tragertt_1-1671486829277.png

If I switch it to ref it shows up but you can only choose one group, some users will have multiple and I would like to use enumlist but if I have to I will use ref

 

 

 

Your setting is correct. In such case, you would need to add the list expression in the Data Validity > Valid_If field.

Steve
Platinum 4
Platinum 4

@Tragertt wrote:

select(users[group], IN([Group], [_Thisrow].[Group]))


Try instead:

select(users[group], IN([_Thisrow].[Group], [Group]))
Top Labels in this Space