Help

Script not identifying Record ID; Returns "undefined"

Topic Labels: Automations
Solved
Jump to Solution
214 4
cancel
Showing results for 
Search instead for 
Did you mean: 
OpsLHPA
5 - Automation Enthusiast
5 - Automation Enthusiast

I am NOT a coder... but this process is slowly making me one (sometimes to my regret).

I am trying to put together a script triggered by a change in a field titled "Invoicing?" on a table named "ALL INVOICES 2024" that will update a different table titled "Client Overview" by adding "Offboard/Last Inv" to a field named "Active/Inactive." These two tables are NOT linked to each other and I don't want them to be, but they do have one field that is identical between the two of them: "Client ID."

After banging my head against a wall for about two days, I decided to just backtrack to the most basic tutorial to see how I might put this together. My first task to "learn" is how to make Airtable identify the record that triggered the script to run. 

I stripped down to the easiest of tasks: Output the Record ID of the table that caused the trigger. I used a bit of code from this article: https://www.airscript.dev/2021/01/31/airtable-automations-scripts

 

let inputConfig = input.config();
console.log(`Record ID is, ${inputConfig.recordId}`);

 

I have identified Record ID in the Input Variables sidebar:

OpsLHPA_0-1707337179897.png

But on test, I am getting "Record ID is, undefined"

OpsLHPA_1-1707337237364.png

I have literally copy/pasted the exact code from the article and I believe I did every step to define the input variable or Record ID. What am I doing wrong?

1 Solution

Accepted Solutions
Sho
11 - Venus
11 - Venus

Just change this to "recordID" here.

change_here.png

See Solution in Thread

4 Replies 4
Sho
11 - Venus
11 - Venus

Hi @OpsLHPA,

Javascript also takes care of capitalization.
If there is a space in the name of the input value, it must be enclosed in quotation marks.

let inputConfig = input.config();
console.log(`Record ID is, ${inputConfig["Record ID"]}`);


// If input value name were "recordID", it would be simpler.

let inputConfig = input.config();
console.log(inputConfig.recordID);

// OR

let {recordID} = input.config();
console.log(recordID);

 

OpsLHPA
5 - Automation Enthusiast
5 - Automation Enthusiast

Thanks. I figured so, but the spaces were as they were printed in the article. I have, however, adjusted it to your shortened version. I am still getting an "undefined" result of the test. 

OpsLHPA_0-1707349216452.png

 

Sho
11 - Venus
11 - Venus

Just change this to "recordID" here.

change_here.png

OpsLHPA
5 - Automation Enthusiast
5 - Automation Enthusiast

Aha! As Daffy Duck would say... "pronoun trouble...."

OpsLHPA_2-1707418223496.jpeg

Thank you!