Dear Community,
I’m very new to Coda, but I can’t help programming all my ideas in my documents .
All the issues I could solve by myself by watching tutorial videos & sample docs of other, but this one.
I have two tables. In the first ([Szintek], means Levels) I defined some groups for my users based on their knowledge (like Beginners, Advanced …).
[Szintek].
[Name]: That’s the name of the level
[Tanulók]: That’s a multiselect People type, which allows me to assign the users to the appropriate groups
The other table i have is [Hírek] (means News). Here I’d like to publish the latest news targeted to one or more user groups (defined in the [Szintek]) table before.
[Hírek].
[Cím]: Just the Title for the news.
[Szint]: Selection field linked with [Szintek].Name
[Hozzárendelve]: A multiselect People field which I’d like to get populated from the [Szintek].[Tanulók] where the [Szint] matches.
I have created a button in the [Szintek] Table with the following Action:
It should do the job, and it does when I press the button for the first row in [Szintek]. However, when I press the button on the second row (to have populated the other group of users to the [Hírek].[Hozzárendelve] fields, it doesn’t just add the users assigned to the second user group, but also adds other users which were populated as I pushed the button for the first time (for the first row).
I have no idea, why… Is it a bug or a feature
Thanks for any advice, as I’m quite stuck …
Hi Nick,
Sure. Splice should add the users of the actual group to the “targeted users” [Hozzárendelve] of the [Hírek] (news) table. It is important, that it retains the users already there, as I click through the button of every rows in [Szintek] one after another to make sure, every assignement is refreshed in the [Hírek] table.
However, in this case you are updating multiple rows at a time. Meaning that the value you are referring to [Hírek].[Hozzárendelve].Splice() is the combination of all the filtered rows.
In order to make it work, you need a reference to each row instance every time. You can achieve this by expliciting an iteration over the filtered rows:
[Hírek].Filter(Szint.contains(thisRow)).FormulaMap(CurrentValue.WithName(row,
row.ModifyRows(
[Hozzárendelve],
row.[Hozzárendelve] //here row.[Hozzárendelve] is actually referring to each row every time and not the full set.
.Splice(1,0,thisRow.[Tanulók]).ListCombine().Unique()
)
))
You’re awesome! Exactly that was the point I was missing. I watch the tutorial with Formulamap, but was not sure I can make use of it in this situation.
Thanks again, I will remember this solution for my rest of my life.