Dec 28, 2023 04:05 PM
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!
Solved! Go to Solution.
Dec 28, 2023 06:19 PM
Dec 28, 2023 05:01 PM - edited Dec 28, 2023 05:01 PM
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
Dec 28, 2023 05:18 PM - edited Dec 28, 2023 05:22 PM
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?
Dec 28, 2023 06:19 PM
Dec 29, 2023 02:14 AM
Thank you very much.
The scenario works perfectly!
Dec 29, 2023 05:50 AM
You’re welcome! Glad I could help! 😄