Post

Luis | 🥷🏽 Underscode
Luis | 🥷🏽 Underscode@underscode_·
For my recurring tasks implementation in @NotionHQ I implemented a formula to generate a summary of when the task will repeat. Here I've used some 'patterns' I use in my Notion formulas. Check this thread to know more about how you can make long formulas better. 👇🏽🧵
Luis | 🥷🏽 Underscode tweet media
English
1
0
18
1.7K
Luis | 🥷🏽 Underscode
Luis | 🥷🏽 Underscode@underscode_·
1. Use direct references to properties only once by assigning to a variable. To make it more maintainable, I use variables at the top of the formula to capture property values, then reference the variable *not the property* from that point on.
Luis | 🥷🏽 Underscode tweet media
English
5
0
2
97
Luis | 🥷🏽 Underscode
Luis | 🥷🏽 Underscode@underscode_·
2. Use maps (arrays of arrays) to avoid too many if/else statements Here I use a _PLURALS map, to dynamically find the singular of days/weeks/months/years/seasons. I also use the _TEMPLATE_MAP to use different templates for the final string depending on how recurrence is set.
Luis | 🥷🏽 Underscode tweet media
English
1
0
2
84
Luis | 🥷🏽 Underscode
Luis | 🥷🏽 Underscode@underscode_·
3. Use indentation With multi-line formulas, I'm super-diligent with indentation, because it gives me clarity on the level of execution each line is operating
Luis | 🥷🏽 Underscode tweet media
English
1
0
1
75
Luis | 🥷🏽 Underscode
Luis | 🥷🏽 Underscode@underscode_·
4. Finally, for text messages in formulas, I like to use 'templates'. A template is basically a string variable with some placeholders, than then get replaced later. Here, I use the same placeholders for all the templates and replace all of them -even if not present- at the end.
Luis | 🥷🏽 Underscode tweet media
English
1
0
2
124
Christian Magill
Christian Magill@christianmagill·
@underscode_ @NotionHQ Some good tips, helps to keep things organized. I tend to use concat and ternary operators. It keeps things pretty flexibile when building collections... for instance for field validation.
Christian Magill tweet media
English
1
0
0
41
Christian Magill
Christian Magill@christianmagill·
@underscode_ @NotionHQ Do you know by chance if you define a group of database items for an automation, and select that variable to edit pages, is there any way to reference the current item of the variable when editing a property based on a formula?
English
1
0
0
67
Paylaş