The Community will be temporarily unavailable starting on Friday February 28. We’ll be back as soon as we can! To learn more, check out our Announcements blog post.
Jun 25, 2022 02:12 PM
Hi All.
I found the following script code for sending a webhook from Airtable to Make but the input.config() in the first line demands an argument.
anyone knows why?
Jesper
let inputConfig = input.config();
let recordID = inputConfig.inputRecord;
console.log(recordID);
let url=‘https://hook.eu1.make.com/7emn6wadgl4bn494kgibfvtop3lf4h6s’
console.log(url);
let request= url.concat(‘?recordID=’,recordID)
console.log(request);
await fetch(request);
Jun 25, 2022 06:06 PM
Are you writing a script using the Scripting Extension/App or an automation?
The code looks like code for an automation script. If you want to run the script from a button you don’t need to use input.config()
to get the triggering record. Instead, use await input.recordAsync()
with the appropriate parameters.
Jun 26, 2022 02:06 AM
Hi again Kuovonne :winking_face:
Thank again fro taking the time.
I’m just trying to get an id from Airtable to Make and I don’t understand how it can be so hard :winking_face:
The first version should be a script called from a button. When I changed the input to a array it now came up with this error.
TypeError: URL is not valid or contains user credentials.
at fetch
at asyncFunctionResume
at promiseReactionJobWithoutPromise
at promiseReactionJob
Here is the code
// Get the airtabel webhook URL
let webhook = ‘https://hook.eu1.make.com/7emn6wadgl4bn494kgibfvtop3lf4h6s’
// Airtable script button name.
let actionDescription = ‘Sending images to processing’
let tableName = ‘MakeTestTable’
let fieldsToSend = [‘Brand2’]
let table = base.getTable(tableName);
let record = await input.recordAsync(actionDescription, table);
let queryParams = ‘/?id=$(record.id)’
if(fieldsToSend.length > 0){
function buildParams(fieldName) {
let fieldValue = record.getCellValueAsString(fieldName)
queryParams += ‘&${encodeURIComponent(fieldName)}=${encodeURIComponent(fieldValue)}’
}
fieldsToSend.forEach(buildParams);
}
const returnedpayload = await fetch(‘${webhook}${queryParams}’);
var payloadResponse = await returnedpayload.json()
let result = payloadResponse.result;
output.text(result)
Can you find the error?
Thanks / Jesper
Jun 26, 2022 06:22 AM
Nope. But it is also really hard to read your code because the forum is messing with the display of your code. When you include code in a post it is helpful to use the code formatting
button at the top of the editor.
You could also try using remoteFetchAsync
Instead of fetch
. See this documentation page for more info.
Jun 27, 2022 01:00 AM
// Get the airtabel webhook URL
let webhook = 'https://hook.eu1.make.com/uiob4x9vxuob2np2wwifebvlqfqenae4';
// Airtable script button name.
let actionDescription = 'Sending images to processing';
let tableName = 'Make test table'
let fieldsToSend = 'Brand 2'
let table = base.getTable(tableName);
let record = await input.recordAsync(actionDescription,table);
let queryParams = '/?id=$(record.id)'
if(fieldsToSend.length > 0){
function buildParams(fieldName) {
let fieldValue = record.getCellValueAsString(fieldName)
queryParams += '&${encodeURIComponent(fieldName)}=${encodeURIComponent(fieldValue)}'
}
fieldsToSend.forEach(buildParams);
}
const returnedpayload = await fetch('${webhook}${queryParams}');
var payloadResponse = await returnedpayload.json()
let result = payloadResponse.result;
output.text(result)
Jun 27, 2022 01:06 AM
let inputConfig = input.config();
let recordID = inputConfig.inputRecord;
console.log(recordID);
let url='https://hook.eu1.make.com/7emn6wadgl4bn494kgibfvtop3lf4h6s'
console.log(url);
let request= url.concat('?recordID=',recordID)
console.log(request);
await fetch(request);
Jun 27, 2022 01:08 AM
Hi Kuovonne.
I’ve now sent you the two versions I’m trying to get working. Does that help ?
Hope you can find the problem.
Jesper
Jun 27, 2022 06:53 AM
It looks like your fieldsToSend
variable got turned back into a text string, instead of an array.
You also didn’t try remoteFetchAsync
.
If those things don’t do the trick, try posting screen shots of the error messages as well. I may not have time to further troubleshoot for you, but someone else might be able to.
Jun 28, 2022 12:23 AM
Ok Kuovonne but thanks a lot for the effort. Great of you to take the time. :winking_face: