Issues with "Formula" for creating mailto links or buttons

There are 3 issues with the concat and encode_uri formulas when it comes to creating links/buttons.

Details below, but here’s the summary:

  1. encode_uri truncates any content that follows a line ending with a comma
  2. in if formula, if the success output is a link/button, it’ll be formatted as text only.

The data

I have a row with person Name, Email, a Payment link, and I want to generate a fully populated mailto link/button.

Here’s some example data:

Name: Alice
Email: alice@example.com
Payment link: https://buy.stripe.com/some_id

Here’s my formula:

button(
  encode_uri(
    concat(
      "mailto:", field('Email'), "?subject=Welcome to the AVID network!&body=",
      concat(
        "Dear ", field('Name'), "

Please submit your payment via this link:

",
        get_link_url(field('Payment link')), "

Regards

The team"
      )
    )
  ),
  "Send email"
)

Comma issue

In the above formula, if I modify the formula to:

...
        "Dear ", field('Name'), ",

Please submit your payment via this link:
...

or

...
Regards,

The team"
...

the resulting mailto will truncate anything that follows the comma, including the comma.

If formula

Wrapping the link/button in an if formula will break the formatting.

If I have if(condition=True, button(..., "Send email"), ''), the output will be just the “Send email” text, without any link/action.

Hi @trapeze6174,

The problem with encode_uri truncating content after a comma can be handled by properly encoding the content before concatenating it. Here’s an updated formula that ensures the encode_uri function works correctly:

  encode_uri(
    concat(
      "mailto:", field('Email'), "?subject=Welcome to the AVID network!&body=",
      "Dear%20", encode_uri(field('Name')), "%0A%0A",
      "Please%20submit%20your%20payment%20via%20this%20link:%0A",
      encode_uri(field('Payment link')), "%0A%0A",
      "Regards,%0AThe%20team"
    )
  ),
  "Send email"
)
  • %0A is used for line breaks.
  • %20 is used for spaces.

It is definitely not the easiest solution so I will bring it to the team’s attention to see how they want to handle these in the future. But in the meantime, you can use the suggested workaround to unblock yourself.

It is true about the if condition breaking the button function. I’ll make a bug report of this and make the team aware.

Here is the bug issue on GitLab for reference: IF condition breaks button formatting (#2809) · Issues · Baserow / baserow · GitLab

Thanks @cwinhall, I’ll use your workaround for now!

@cwinhall when you create the bug report: it’s not commas at the end of the line that trigger truncation, but commas in general, only tested now.