A somewhat of a documentation of hidden formulas [Added mechanics of nested buttons]

How to prevent total destruction of your document [Back to index]

Hidden formulas can be extremely dangerous and destructive.
That’s why it is crucial to take proper precautions when using them in any document.

The issue
As it was said earlier, some hidden formulas can permanently crash your document if they have a syntax error (this happens, for example, if you use incorrect color name). Normally this isn’t a huge issue as you can revert to the previous version using version history.

But now imagine this - all your hidden formulas are working when you created them. However, after a few months there’s an update which changes their syntax, and now previously working formulas crash your document (this is a completely plausible situation since experimental formulas don’t have to be backwards compatible).

Since it’s not a change in your document that caused the crash, you can’t just revert to the previous version. You would have to revert to the last version which doesn’t use the hidden formulas that crashes, which would mean enormous amount of data loss.
You can’t edit the formula since the crash happens the very moment the document loads, and currently there is no way to access raw save file, which means you lost the whole document.

What now?
While you can’t recover the whole document you may be able to recover some of its data.
When you enter version history, none of the formulas are being executed. That means you can use this to manually copy data from visible cells.

How to ensure access to your document
There is a way to prevent this situation before it happens.
Formulas aren’t being calculated if they are not visible, which means that the document won’t crash if there aren’t any broken formulas in your current section.

The idea is to use this and create a fail-safe section which doesn’t use any hidden formulas.
In case your document crashes you can use direct link to this section to open the document without the crash.

You have to create this section while you document is still working. Otherwise, none of the following paragraphs will help you.

It is also important to keep a direct link to this section somewhere outside of the document.
Just typing “/section-name” won’t work, it needs to be followed by the section id.

Fixing the document
Now that you have access to your document you can start fixing it.
You can do that by removing all rows from the broken table. Since you can’t directly display the table, you will have do that using a button and delete rows action.

With a few additional buttons you can also copy all data from the broken table, as shown in the document below.

Easier way to fix the document
There is another precaution you can take to make fixing the document significantly easier.

By adding a checkbox control to the fail-safe section and then wrapping each formula that uses experimental features with if(checkbox,"",...), you can fix crashing with a single click of a button.
After that you can open the section with the broken table and fix the invalid formula.

It is also a good idea to turn this checkbox on whenever you create a backup of your document, just in case.

Additional precautions
It may be a good idea to also create another section called “raw data”.
It should contain a view for all tables that can contain data inputted by the user. If everything else fails you’ll still be able to manually copy user data from version control.

And under no circumstances should you put that table in the same section as the fail-safe. You would risk loosing the whole document.

Crash sandbox
Here is a document which allows you to play with the crashing mechanics of coda.io and has implemented the precautions explained above.
(You have to copy this document in order to fully see how those precautions work)

Additional notes
All of the above precautions are based of current (August 2019) coda mechanics.
That means that, even though it’s extremely unlikely, they may no longer be working after a few updates.

6 Likes