Changing a string of text using a button

Hello everyone.

I’m trying to change a string of text inside a cell using a button.
I wish to replace the “xxx” in the highlighted column to a number related to the project (derived from a column in a different table).

I did my best at writing a formula inside the button using the “replace” function but with no success (formula seen in attached JPG).

In the following example all the “xxx” should be replaced with “003” so that the full name will be “a-003-100-dem” (for the first row), “a-003-101-binuy” (for the second row), etc.

Would appreciate some help.
If the Hebrew is an issue, I’ll upload a table in English.

Thx in advance,
Ranny

Table from which the project number is taken:

Hi @Ranny_Shor ,
would it be possible to share your doc (or a sample of it)?

Do you receive any error when pushing the button?
Is the affected column already a Formula column?

Alternatively, could you write the full formula generated by the button (if you click the “f” in the button details you should see the whole formula based on the settings in the interface).

Thank you!

Hi Federico, thanks for the quick reply.
Pls find attached a summarized table.

The button is at the bottom. It is supposed to replace the “xxx” in the column “drawing code” from the second table (Drawing list) with the number related to the project from the first table (Project list) - “004” in this specific example (Albright = 004).

Thanks,
Ranny

Dear @Ranny_Shor,

It has nothing to do with your question, please be careful displaying personal information like phone numbers and email addresses.

1 Like

Thanks for the comment.
All numbers and e-mail addresses are made up, but I’ll keep in mind to remove such columns in the future.

Ranny.

Hi @Ranny_Shor,
I think I found the reason why.
I have already provided am alternative button that performs the substitution.
Here’s the formula with some explanations:

[Drawing List].Filter([Drawing code].RegexMatch("xxx")) // filter all the values containing the matching pattern
  .FormulaMap(CurrentValue.WithName(row, // for each record, give it the name "row"
        row.ModifyRows(  // and FOR EACH row, modify it by... 
            [Drawing List].[Drawing code], // ... changing the Drawing code column
            [Drawing code].RegexReplace("xxx", project.[Project #]) // replacing the search pattern with the desired value IN THAT ROW
          )
      )
  )
  1. The key concept here is the iteration: you can use ModifyRows() after the filter, but in that case you don’t have the single row access. You were asking: “replace all the filtered rows with all the product values” (rather than each-each).
  2. WithName() function could be omitted here and just using currentValue. I tend to use it anyway because it helps me to better define the context.
  3. I just changed the Filter() condition and the Replace() with RegexFind/Replace(). It seemed more convenient and extensible to me, but your solution was absolutely OK.

I hope this helps. Please, tell me otherwise.
Cheers!

1 Like

Hi Federico - It works perfectly!
Thank you so much for the solution and for the detailed explanation.
Sort of new to Coda and you opened my eyes to some new possibilities inside formulas.

Thanks again and all the best,
Ranny

1 Like