Help

Problem with a script

704 2
cancel
Showing results for 
Search instead for 
Did you mean: 
Jesper_Lauridse
5 - Automation Enthusiast
5 - Automation Enthusiast

Hi everyone.
I’m trying to follow this guide and I’m told to setup this script but Airtable is complaining about this fieldsToSend.forEach

saying that forEach dosen’t exists on type string but I just copied it so it must work for him.

Does anyone know?

Here is the complet code

// 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 = ‘Test Make’

let fieldsToSend = ‘Brand’

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)

}

}

2 Replies 2

Welcome to the Airtable community!

You probably changed the value of the fieldsToSend variable. It is currently a text string. Before was it an array of text strings? What was that original line like? What happens if you make it an array?

Thanks for the quick reply. I was missing some barckets :winking_face: