Help

Re: Run a webhook by checking a checkbox

Solved
Jump to Solution
2608 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Nocode34130
5 - Automation Enthusiast
5 - Automation Enthusiast

Hi everyone,

I'm learning airtable scripting and what i want to do is this :

-When a check a checkbox in my table, it run a script which will fetch a webhook. The webhook's url is concatenate with the webhook's url and the recordID.

My script is running well but it concatenate only the recordID from the row 01. Whenever i checked another box from another row...

My question is : is there a solution to concatenate with, my webhook's url, the recordID from the row that i checked the box ?

Here's my script : (a mix of everything I found on the internet)

 

let table = base.getTable("Ligne - Matériel");
let queryResult = await table.selectRecordsAsync({fields: ["recordID"]});
let record = queryResult.records[];
let request= url.concat('?ref=', record.getCellValueAsString("recordID"))
await fetch(request);
 
Thanks a lot !
1 Solution

Accepted Solutions
kuovonne
18 - Pluto
18 - Pluto

If you only need the record ID of the triggering record, you don't even need to run a query. Just get the record ID from an input variable.

You will need to create the input variable in the left side of the automation script editor. Give it the name recordID and set its value by picking the record ID of the triggering record.

let url="https://hook.eu1.make.com/XXXXXXXXXXXXXXXXXXXXX"
let recordID = input.config()["recordID"]
let request = url + '?ref=' + recordID
await fetch(request);

 

See Solution in Thread

4 Replies 4
Ben_Young1
11 - Venus
11 - Venus

Hey @Nocode34130

I need to preemptively write this before you read on. I'm about to run out the door, so I can't type a more in-depth post, but the script you posted will query for every record in your table and return an array of those record objects.

Here's a tweaked version of the script you posted.

 

const table = base.getTable("Ligne - Matériel");
const records = await table.selectRecordsAsync({ fields: ["recordID"] })
    .then(query => query.records);
    
const sendRequest = async record => {
    let url = `https://hook.eu1.make.com/XXXXXXXXXXXXXXXXXXXXX?ref=${record.getCellValueAsString("recordID")}`;
    return await fetch(url);
}

records.forEach(async record => await sendRequest(record));

 

If you want to only send a request for the record that triggered the automation, you need to pass the record ID of the subject record to the script's input variables and then change the invoked method from the table.selectRecordsAsync to table.selectRecordAsync method. It would look something like this:

 

const { recordId } = input.config();
const table = base.getTable("Ligne - Matériel");
const record = await table.selectRecordAsync(recordId);

const sendRequest = async record => {
    let url = `https://hook.eu1.make.com/XXXXXXXXXXXXXXXXXXXXX?ref=${record.getCellValueAsString("recordID")}`;
    return await fetch(url);
};

if (record) {
    await sendRequest(record);
}

 

kuovonne
18 - Pluto
18 - Pluto

If you only need the record ID of the triggering record, you don't even need to run a query. Just get the record ID from an input variable.

You will need to create the input variable in the left side of the automation script editor. Give it the name recordID and set its value by picking the record ID of the triggering record.

let url="https://hook.eu1.make.com/XXXXXXXXXXXXXXXXXXXXX"
let recordID = input.config()["recordID"]
let request = url + '?ref=' + recordID
await fetch(request);

 

Nocode34130
5 - Automation Enthusiast
5 - Automation Enthusiast

A great thanks for both of you ! It's works perfectly :-)))))

ScottWorld
18 - Pluto
18 - Pluto

For others who are reading this thread and need more detailed instructions on how to set this up, I have written up an entire tutorial on this topic (with screenshots) here.