How to encode a URL in an action field?

Goal: I have built a table that has action fields, 1 of which opens a webpage in a new window that currently uses a formula to figure out the URL. This works EXCEPT when a specific field in the formula has special characters.

My goal is to encode the field Title in the formula below so that it works encodes correctly and the link works.

Current formula in the editor:

http://twitter.com/intent/tweet?text={{table1.selectedRow.data.Title}} is {{table1.selectedRow.data.field1}} {{table1.selectedRow.data.field2}}

I believe I should use encodeURIComponent, I tried it a few different ways but it seemed to pass the words "encodeURIComponent" instead...

Thank you!

Hi @user20202,

I think you're most of the way there, I'm not entirely sure if the twitter part is in field1 or if it's hard coded, but hopefully this gives you enough of an idea to get it working with your variables.

{{ encodeURIComponent(`${currentRow.field1}${currentRow.field2}`) }}

So it would look like this in the action config window.

image

Assuming the following:
currentRow.field1 = "http://twitter.com/intent/tweet?text="
currentRow.field2 = "Some tweet text"

This part just turns both parts into a text string, so
${currentRow.field1}${currentRow.field2} = "http://twitter.com/intent/tweet?text=Some tweet text"

And then the whole thing is wrapped by encodeURIComponent, so the result is "http%3A%2F%2Ftwitter.com%2Fintent%2Ftweet%3Ftext%3DSome%20tweet%20text"

I don't know if that's exactly what you want, because encodeURIComponent will encode the whole thing, including all parts of the URI syntax (https://), so you may need to try encodeURI() if this isn't working for you.