Button to use text control to set relation value

Hey there,

I’m having an issue with a button I’ve set up in my Coda doc. The button is supposed to add a value from a canvas text control (DocOpenValueProjects) to a column (PrioDocs) in the same row. Here’s a bit more context:

PrioDocs is a relation to another table, and it’s set up as a multi-select column, meaning it can hold multiple values at once.

• The button’s job is to take the value from DocOpenValueProjects (a canvas text control) and add it to PrioDocs without losing any of the existing values already stored in PrioDocs.

ModifyRows(thisRow, thisRow.PrioDocs, DocOpenValueProjects)

However, the issue I’m running into is:

• The button works, but instead of adding the new value to the existing ones in PrioDocs, it overwrites everything else in that row. So, I end up losing all the previously selected values in PrioDocs, which isn’t what I want since PrioDocs is supposed to allow multiple selections.

What I’ve tried:

I’ve tried using ListCombine and other similar approaches to combine the existing values in PrioDocs with the new value from DocOpenValueProjects. However, these methods don’t seem to write the value in the correct way. Either the value doesn’t get added properly, or it loses its formatting (like the outline) and shows up incorrectly in the list.

I’d love a way to modify this formula so that the value from DocOpenValueProjects gets added to the existing values in PrioDocs without overwriting them and ensuring that it retains the correct formatting and structure.

Has anyone dealt with something similar or have any advice on how to tweak this so it works correctly?

Thanks in advance!

How to get there (short loom video)

Hey @Bjoern_Martens - You do use the ListCombine function to do this. My guess is the formula is needs to be corrected.

Can you share you doc or make a copy and share the copy?

Here you go! Let me know if you can’t copy it. Thank you :pray:t3:

It wasn’t working with ListCombine because DocOpenValueProjects is a string not a Project row reference. So you need to find the Project row that matches that string with Projects.Filter(Project= DocOpenValueProjects). This formula will get you want you’re looking for.

ModifyRows(
  thisRow,
  thisRow.PrioDocs,
  ListCombine(
    thisRow.PrioDocs, 
     Projects.Filter(Project = DocOpenValueProjects)
  ).Filter(CurrentValue != "").Unique()
)

On another note the DocOpenValueProjects personal control is a text box. To simplify the above formula and reduce brittleness you may want to consider changing the DocOpenValueProjects control from a text box to a relation. That way DocOpenValueProjects can only be set to a valid project and not to text that may not be a valid Project name. If you do that the ListCombine portion of the above formula just becaomesListCombine(thisRow.PrioDocs,DocOpenValueProjects).

Hope it helps!

It definitely helped. Thanks a lot! Genius!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.