I am really glad to be in the community. Coda is amazing and I still cannot believe the endless opportunities of customization it has.
Recently, we wanted to automate emails with the data we already have in our data base. That is how I stumbled upon this topic. I played with the published docs and it took me some time to really understand them. The more I used them, the more I liked them. I am writing this post just to summarise my experience using the docs and to share some ways we use them to automate emails.
How to make your own variables
To make our own variables we need to use RegexReplace formula. What the RegexReplace does is finding the specified expression and replacing it with with the data from certain table row. This makes is extremely powerful, because it could use that we already have in the data base. There are two places, where the RegexReplace formula is used:
- in the button, which sends the email - I believe it is hidden by default
- in the full email code - just go to the bottom of the code and right click. The formula will pop up.
To add variable in the email, all you need to do is make some placeholder like for example ^RANDOM^ and use it in the email builder. Next you need to add the RegexReplace formula in the send button. First, you need to add a new column, which will contain the information. In this case let’s say we make a column “Random”. The formula is really simple and looks like this:
That is it! You can use it as many times as you would like. It’s amazing how easy and yet powerful this is!
Difference between the formula in the send button and in the full html code
There is an important difference whether we use the RegexReplace formula in the Full email code or in the Send to table. In the first case we get all the rows data and in the second just the data from the said row. This may be obvious for most of you, but for non experienced users like me it takes some time to get.