I’m trying to create a script to create new records in Airtable, fill out various fields, using the Drafts Prompts. I’m using the wonderful Airtable API for drafts to make communicating with Airtable easier, but I need some help with controlling the flow/error handling.
I understand there is no way to hard-exit from a script, and it seems tedious/difficult to separate the script into smaller script action steps to be able to use context.cancel for this. Do I have to wrap the script in nested if statements (one for each prompt)? That doesn’t seem very clean or readable…
I’m trying to avoid this:
let con = p.show();
if (con) {
let con = p.show();
if (con) {
let con = p.show();
if (con) {
etc.
}
}
};
Is this a better way to do it:
let con = p.show();
let con2 = false;
let con3 = false;
let con4 = false;
if (con) {
con2 = p.show()
}
if (con2) {
con3 = p.show()
}
etc.
It’s probably quite obvious that I’m no programmer by now, but is there a better way to handle this? I want to be able to stop the script whenever a prompt is cancelled, to avoid going through the rest of the prompts.