Skip to main content
Solved

Script not identifying Record ID; Returns "undefined"

  • February 7, 2024
  • 4 replies
  • 131 views

Forum|alt.badge.img+3

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:

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

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?

Best answer by Sho

Just change this to "recordID" here.

4 replies

Forum|alt.badge.img+21
  • Inspiring
  • February 7, 2024

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);

 


Forum|alt.badge.img+3
  • Author
  • New Participant
  • February 7, 2024

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);

 


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. 

 


Forum|alt.badge.img+21
  • Inspiring
  • Answer
  • February 8, 2024

Just change this to "recordID" here.


Forum|alt.badge.img+3
  • Author
  • New Participant
  • February 8, 2024

Just change this to "recordID" here.


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

Thank you!