Help

A problem with a script that exports data to Make

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

Hi

I have a script which exports data from Airtable to Make.
It exports 3 record columns in total.
The trigger is a new created record.

The output returns the same record every time, which is not even the newest, just a random out of the list.
I'm quite clueless at the moment and appreciate any assistance in this matter.

 

The script is attached:

 

let apiKey = 'XXXXXX'; // Replace with your Airtable API key
let baseId = 'XXXXXX'; // Replace with your Airtable base ID
let tableName = 'Data'; // Replace with your table name

let integromatWebhookURL = 'https://hook.eu1.make.com/lltvxgqpxuvehximley444ibk3vcqkw9'; // Replace with your Integromat webhook URL

let table = base.getTable(tableName);

let query = await table.selectRecordsAsync({
fields: ['Quote Number', 'ID', 'Client Name'],
sort: [{ field: 'Quote Number', direction: 'desc' }],
});

if (query.records.length > 0) {
let record = query.records[0];

console.log('Client Name:', record.getCellValue('Client Name'));

let dataToSend = {
'Quote Number': record.getCellValueAsString('Quote Number'),
'ID': record.getCellValue('ID'),
'Client Name': record.getCellValueAsString('Client Name'),
};

// Trigger Integromat scenario using HTTP POST request
let response = await fetch(integromatWebhookURL, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + apiKey,
},
body: JSON.stringify(dataToSend),
});

if (response.status !== 200) {
console.error('Failed to trigger Integromat scenario:', response.status, response.statusText);
} else {
console.log('Integromat scenario triggered successfully!');
}
} else {
console.warn('No records found to trigger Integromat scenario.');
}

 

Thank you!

1 Solution

Accepted Solutions
ScottWorld
18 - Pluto
18 - Pluto

Take a look at this screenshot. Your next module will need to be the Airtable Get A Record module

See Solution in Thread

5 Replies 5
ScottWorld
18 - Pluto
18 - Pluto

It looks like you’re trying to send Airtable record data to a Make webhook. Have you tried the approach that I’ve outlined in this thread: https://air.tableforums.com/t/sending-airtable-data-to-an-external-webhook-such-as-make-com/159

 

Nitzan_Englende
5 - Automation Enthusiast
5 - Automation Enthusiast

Hi Scott

When I run all whole scenario, I get a weird output.
It doesn't happen when I test the automation (when everything works fine).

It identifies the ID, but the Quote and Name stay null and empty.

Why does it happen?

Nitzan_Englende_0-1703812724244.png

 

ScottWorld
18 - Pluto
18 - Pluto

Take a look at this screenshot. Your next module will need to be the Airtable Get A Record module

Nitzan_Englende
5 - Automation Enthusiast
5 - Automation Enthusiast

Thank you very much.

The scenario works perfectly!

You’re welcome! Glad I could help! 😄