Help

Upcoming database upgrades. Airtable functionality will be reduced for ~15 minutes at 06:00 UTC on Feb. 4 / 10:00 pm PT on Feb. 3. Learn more here

Exit automation script before reaching the end

Solved
Jump to Solution
118 2
cancel
Showing results for 
Search instead for 
Did you mean: 

I am writing an automation script that takes an input X. I lookup X in a table, and then go on and do stuff with what I've found.

But if the lookup comes up empty, (no qualifying records), I want to exit the script. I could do this:

if (X was not found in table) {
    output.set("error", `${X} was not found`)
} else {
    // do stuff
}

But this gets messy. If I need to lookup X, and then Y, and then Z, then each additional lookup results in more indentation of my code. What I'd like to do is this:

if (X was not found in table) {
    return from script
}

"return" isn't allowed. Googling has not provided an answer.

Is there any way to do what I want?

1 Solution

Accepted Solutions

No idea if this is the "Right" way, but you could just wrap everything in a function and do the return from there?

Screenshot 2022-12-22 at 12.57.59 PM.png

See Solution in Thread

2 Replies 2

No idea if this is the "Right" way, but you could just wrap everything in a function and do the return from there?

Screenshot 2022-12-22 at 12.57.59 PM.png

Oh, right. Yes, that is perfect.