Help

The Community will be undergoing maintenance from Friday February 21 - Friday, February 28 and will be "read only" during this time. To learn more, check out our Announcements blog post.

let recordId = input.config().recordId...

Topic Labels: Automations
213 2
cancel
Showing results for 
Search instead for 
Did you mean: 
alfa
5 - Automation Enthusiast
5 - Automation Enthusiast

Hello again - 

I'm having trouble getting an Interface button to call a recordId when it is pressed. I created an interface view of a Record List for an Attendance table and even though the button is in the Record Detail view (Pic #1), I can't get it to send a RecordID to the automation. I've rebuilt the interface multiple times and the automation.

But, when I run the automation within the table and click the button in the column, it works. But not entirely: I created a webhook>docupilot>gmail workflow to make a PDF and send an email. I have the Immediately as data arrives switch ON in Make, but, it doesn't do that. I have to click Run once - Wait for new data, then, go in Table view and hit the button and then it works. Automation json attached too.

My whole goal is to have it so I can at least just click the button of all the rows on by one in Table view (Pic #2) and the automation through Make processes the pdfs (I'm making pdf certificates for rows that appear in the Table and clicking the button). 

Thank you so much.

Here is the code from the Automation:

let table = base.getTable("Attendance");
let recordId = input.config().recordId;

console.log("Debugging Record ID:", recordId); // More detailed debugging output

if (!recordId) {
console.log(" Error: No record ID received. Check button settings in Interface.");
console.log(" Ensure 'Airtable Record ID' is selected in the Input Variables.");
return;
}

// Fetch the selected record
let record = await table.selectRecordAsync(recordId);
if (!record) {
console.log(` Error: Record with ID ${recordId} not found in Attendance table.`);
return;
}

// Extract Data from the Selected Record
let name = record.getCellValue("Name") || "No Name";
let session = record.getCellValue("Session") || "No Session";
let email = record.getCellValue("Email") || "No Email";

console.log(` Processing Record - Name: ${name}, Session: ${session}, Email: ${email}`);

if (!email) {
console.log(" Error: Email is missing. Cannot send PDF.");
return;
}

// Send data to Make.com Webhook
let webhookURL = "https://hook.us2.make.com/itn6nrr2fgpgb8e72vtv998kv3yyotj8"; // Replace with your Make Webhook URL

let response = await fetch(webhookURL, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
"name": name,
"session": session,
"email": email
})
});

if (response.ok) {
console.log(" Success: PDF request sent to Make.com!");
} else {
console.log(" Error: Failed to send request to Make.com.");
}

And here is the code from the table/extensions:

let table = base.getTable("Attendance"); // Change this to match your table name
let record = await input.recordAsync("Select a record", table);

if (!record) {
output.text("No record selected!");
return;
}

// Extract Data from the Selected Record
let name = record.getCellValue("Name");
let session = record.getCellValue("Session");
let email = record.getCellValue("Email");

if (!name || !session || !email) {
output.text("Missing required fields. Ensure Name, Session, and Email are filled.");
} else {
// Send data to Make.com Webhook (Replace with your Make Webhook URL)
let webhookURL = "https://hook.us2.make.com/itn6nrr2fgpgb8e72vtv998kv3yyotj8"; // Replace with your Webhook URL from Make.com

let response = await fetch(webhookURL, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
"name": name,
"session": session,
"email": email
})
});

if (response.ok) {
output.text("PDF request sent successfully!");
} else {
output.text("Error sending request to Make.com.");
}
}
2 Replies 2
ScottWorld
18 - Pluto
18 - Pluto

Did you setup your input.config() variable in the left margin of your “run script” action? You can see how to do that in my instructions in this post.

- ScottWorld, Expert Airtable Consultant

Hmm, what does your automation history output?  You should be able to see from your run history what issues your script ran into.  If you can send me a DM with a link to your base I could take a look at that for you!