Previously in Formulas you had to do a lot of work to copy automation-based formulas as described in my post Dealing with Copy and Paste Errors with Formulas in Notion Formulas 2.0.
No more!
We now have two new functions for helping us share formulas in automations.
Context
context accepts the name of built-in variables and data from an automation run and turns them into a valid Formula token.
This means writing the formula context("Trigger page") will turn into the built-in Trigger page token when pasted.
And vice-versa! So when we copy a formula to share it with someone else, we get a nicely human-readable formula!
context("Trigger page")
.prop("Project")
.map(current.prop("Clients"))
.flat()
.unique()
Much better than how it used to copy:
{"global":"button_page","source":"global"}
.prop("Project")
.map(current.prop("Clients"))
.flat()
.unique()
Now I don’t have to do any cleanup work when copying and pasting in a Formula that was shared with me. Amazing!
So context is used in these built-in mentions. It’s also used when we use Add page in… steps in our automations. If you only have one, it’ll be a “Page added”…
context("Page added").prop("Frame")
More than one? “Page added in step {n}”.
context("Page added in step 1") + context("Page added in step 2")
Var
var accepts the name of a variable created in a Define variables step in an automation.
"Hello" + var("Variable 1")
In the above, I would have created a variable called “Variable 1”:
When I paste in var("Variable 1"), Notion now auto-tokenizes this for us!
Copy and paste in automations means Formula examples are much more shareable and now that things are named exactly as they are tokenized, it’s much easier to understand what a Formula is doing at first glance.
A very welcome update to Formulas!