Since day one of using retool it bugged me that I had to manually make sure some component or query variable is not empty.
I recently started adding some preloaded JS, and thought I'd share my most used snippet.
Add the following code to your preloaded JS (found at [orgName].retool.com/settings/advanced):
window.cUN = (value) => {
if ( typeof value == 'undefined' || value === '' || value === null || value !== value ) return true;
else return false;
}
When done, whenever you need you can quickly check if value is empty like this:
{{ cUN('') }} // True
{{ cUN(NaN) }} // True
{{ cUN(null) }} // True
{{ cUN(undefined) }} // True