Challenge with Implementing Dynamic Buttons Using Concatenation in Formulas

Hello Baserow Community,

I’m facing a challenge with creating dynamic buttons directly in formulas. My aim is to embed a concatenated URL within a button function. The initial formula I tried was:

button(concat('https://example.com/databases?tab=assets&search=', field('Nom'), '&view=list'), 'TEST')

This direct approach didn’t work. Instead, I had to use a separate field for the URL concatenation before referencing it in the button function:

button(field('Concatenated URL'), 'TEST')

Is there a method to concatenate within the button function itself, bypassing the need for an additional field? Any guidance or tips would be greatly appreciated!

Thank you! :slight_smile:

Hi,

I just tested the formula button(concat('https://example.com/databases?tab=assets&search=', field('Nom'), '&view=list'), 'TEST') and it worked fine. Can it have something to do with the content in the Nom field?

Hello @frederikdc ,

Thank you for testing the formula and providing your feedback. Indeed, the issue might be related to the content in the ‘Nom’ field. The examples you asked for are as follows:

  • Système de sécurité incendie_0020001500020001
  • Système de sécurité incendie_0020000O00020001
  • Système de sécurité incendie_0020001400020001
  • Système de sécurité incendie_0020000500020001
  • Système de sécurité incendie_0020000L00020001

It appears that these entries contain special characters or sequences that might be affecting the formula’s behavior, especially considering the use of underscores and possibly alphanumeric sequences that include a mix of numbers and letters.

I’m wondering if certain characters within these strings are causing encoding issues or conflicts with the URL format expected by the formula. Do you have any suggestions on how to handle such cases, or is there a specific format or character encoding I should use to ensure compatibility?

Looking forward to your insights.

Yes, you can solve it using the encode_uri function:

button(concat('https://example.com/databases?tab=assets&search=', encode_uri(field('Nom')), '&view=list'), 'TEST')
1 Like

Hello @frederikdc ,

Fantastic news! Your suggestion to use the encode_uri function in the formula worked perfectly. The formula now functions as intended:

button(concat('https://example.com/databases?tab=assets&search=', encode_uri(field('Nom')), '&view=list'), 'TEST')

This has resolved the issue, and I’m thrilled with the outcome. Thank you so much for your help and for sharing this solution. :slight_smile: