Preamble
If you’re a Notion formula creator, you may have noticed that copying and pasting formulas in automations does not really work as it does in the database-driven formula editor. This has been endlessly frustrating for me as an educator and formula fan as it makes sharing formulas really difficult.
This guide is one parts documentation, one part mitigation guide, and one part future speculation and hopeful about how copying and pasting might work in the future.
I know Notion’s automation team is working on making this feature fully work and I’ve shared my thoughts on how I’d love it to work, but in the meantime, perhaps this will be helpful in understanding how to use copied Notion formula examples in automations.
Current Situation
Before we look at our first formula in an automation, it’s important to take a quick look at how formulas copied and pasted from the standard editor in non-automation contexts work. As you’re aware by now, I can give you a formula example like so:
prop("Values")
.map(current.prop("Value"))
.sum()
And you know if you paste that into a regular formula editor that Notion will automatically convert the first prop
call into a property token referencing the Values
relation as well as a Value
token for the property token on the Values database (assuming you have the exact properties in your database already).
However, consider a formula like the following in an automation step—for example, a Define variables step.
If we copy and paste this formula out here’s what we end up with:
.
.map(current.)
.flat()
.unique()
That is not a broken blog post. That’s actually how it pastes into a code block in Notion. No token references whatsoever. So we cannot copy and paste this example into another editor because it’s missing all of the context. As a “copier”, we can’t tell what is supposed to be referenced in the above formula. What property is being map
ped?
What about if we use the paste without formatting shortcut (cmd + option + shift + v) on macOS:
{"global":"button_page","source":"global"}
.prop("Project")
.map(current.prop("Clients"))
.flat()
.unique()
Well that’s interesting!
Indentation isn’t working fully, we seem to have some prop
calls for our Project and Clients, and now we get some interesting JSON objects in the place where some of our Trigger page
property token should be.
But what are these?
Turns out that each of the specific-to-automations formula properties (ex. Trigger page
) have a corresponding JSON representation when copied and pasted.
The workaround to sharing formulas then is to identify which JSON blob is in the pasted formula and replace it with the correct corresponding token. To figure out which token to replace the JSON with, check out the mitigation steps below.
Mitigation
I’ve recorded a video showing how I work around these issues in my own formulas and educational documentation. Unfortunately sharing and documenting formulas in automations is really obnoxious right now since the feature isn’t complete.
I’ve published a Notion Database with these replacement values here. They are also listed below.
Token | JSON | Global |
---|---|---|
Date triggered | {"global":"today","source":"global"} | today |
Page added | {"action_id":"ACTION_ID","action_output_type":"page","source":"action"} | action_id |
Page creator | {"global":"page_creator","source":"global"} | page_creator |
This page | {"global":"button_page","source":"global"} | button_page |
Time triggered | {"global":"now","source":"global"} | now |
Trigger page | {"global":"button_page","source":"global"} | button_page |
Whoever clicked | {"global":"current_user","source":"global"} | current_user |
Whoever triggered | {"global":"current_user","source":"global"} | current_user |
In short, writing your own formulas isn’t all that bad, but if you’re attempting to share with others, your best bet is to share the formulas actually built into a duplicatable database. The second not-so-good option is to give them the full version with the JSON snippets and direct them to the translation guide I’ve provided.
Future Speculation
Notion is definitely working on addressing this issue for formula pros. Based on their thinking I shared the following around how the language support could be extended similar to prop
with other representative functions that could be translated into tokens.
globalVar
This method does not exist conceptually, but I think it’d be super cool to be able to access actually global data in formulas; from the workspace; from users; etc.
Currently Notion calls things like Trigger page
globals, but they don’t really seem like “available anywhere” global variables to me. Global variables would be something like…
Current User
(likeMe
in filters, we could then use the current user in formulas to show content relevant to us).Workspace
(likeuser()
but to access information about the workspace)group(name: string)
(likeuser()
but for groups)Users
(list of all workspace users)
For example, in the editor you might see a token called Current User
and when copied and pasted for sharing, it’d show up as globalVar("current_user")
.
These would be referred to as globals because they would be accessible in any database and do not require the current database row as context.
contextVar
This would be for looking up variables in the current context. Basically everything shown in the table above.
Page creator
Whoever clicked
- et al
For example, in the editor you might see a token like Page creator
and when copied and pasted for sharing, it’d show up as contextVar("page_creator")
.
actionVar
This would be for named variables created in Define variables steps. So if you define a variable called My Var
it’d copy and paste as actionVar("My Var")
.
prop
Prop could remain as-is, but…
It’d be debatable, but it might be easier and more understandable to overload the prop()
API as something like the following:
prop(name: string, context: string = "prop") => any
This would allow the standard prop("My Prop")
to continue working while also allowing for something like:
prop("current_user", "global")
prop("page_creator", "context")
prop("My Variable Name", "action")
prop("My Prop")
orprop("My Prop", "prop")
Of course, this is all speculation, but as a programmer guy and a big formula fan, this is fun to think about and hopefully the Notion team might take me up on some of this thinking.
Getting copying and pasting working in automations would be a huge win for the Notion education community.
What would you like to see designed for this complex scenario? @ me on Bluesky with your thoughts.