Unit 3
Scripts Workshop
Guided challenges on Airtable scripts. Read a line, find what breaks, and choose between a script and native actions. The terms are defined on the Module 3 overview.
Challenge: Read the Line
Part of each line is explained. Answer the question about the rest
const { invoiceId, clientEmail } = input.config(); input.config() is a method call. It returns an object with one property for each input variable configured on the script action.
What does const { invoiceId, clientEmail } = do with that object?
This is destructuring. The curly braces on the left name the properties to read from the object, and each one becomes a variable.
The object returned by input.config() isn’t changed. The line reads from it.
Input variables are configured on the script action in the automation editor. A script can read them and can’t create them.
Arguments go inside the parentheses of a call. The parentheses of input.config() are empty.
The answer: Declares two variables, invoiceId and clientEmail, and assigns each one the value of the property with the same name.
This is destructuring. The curly braces on the left name the properties to read from the object, and each one becomes a variable.
Challenge: What Breaks
Each script has one mistake. Work out what value or error it produces
The script action has one input variable, named OrderID.
-
OrderIDRecord ID, from the trigger
const { orderId } = input.config(); input.config() returns an object with one property, OrderID.
What value is assigned to the variable orderId?
Property names are case-sensitive. OrderID and orderId are different names.
Destructuring a property that doesn’t exist assigns undefined. The script continues and fails on a later line that uses orderId.
Airtable doesn’t check the variable names in the script against the input variables. The mismatch appears only when the script runs.
The answer: undefined, because the object has no property named orderId.
Destructuring a property that doesn’t exist assigns undefined. The script continues and fails on a later line that uses orderId.
Challenge: Script, Native Actions, or Extension
Read the trigger and the requirement, then choose what to build it with
- Trigger
- When a form is submitted.
- Requirement
- Send an email to the address in the submitted record.
Which should this be built with?
One trigger and one Send an email action. The automation has no records to iterate over and nothing to calculate.
A script would do what one native action does, and the automation would be harder for someone else to maintain.
The Scripting extension runs when a user clicks Run. This has to run on every form submission.
The answer: Native automation actions
One trigger and one Send an email action. The automation has no records to iterate over and nothing to calculate.