The Airtable Community will undergo scheduled maintenance on September 17 from 10:00 PM PST to 11:15 PM PST. During this period, you may experience temporary disruptions. We apologize for any inconvenience and appreciate your understanding.
Aug 04, 2023 01:09 PM - edited Aug 04, 2023 01:09 PM
Hi there,
I'm new to the Airtable Community and was hoping someone here might shed some light on a script I'm trying to implement. I am receiving data from a third party form via an AT Webhook. I need to concatenate the image path (ImgPath) submitted from the form when it includes an attachment to create a full URL and then update the PhotoURL field which is set as an attachment in the current record in my AT table . However, when I test my script I get the error:
Error: Field "fldAjZqtaQu8IMl9F" cannot accept the provided value.
Below is the relevant section of myscript:
let imgURL = `https://mydomain.com/${ImgPath}`;
const table = base.getTable("Entries")
const query = await table.selectRecordsAsync({fields:["ImgPath", "PhotoURL"]})
let record = query.records[0].id;
await table.updateRecordAsync(record, {
"PhotoURL": imgURL
})
I see plenty of examples where the update is triggered to batch update the entire table but I am hoping to do the update with each individual Webhook submission.
Solved! Go to Solution.
Aug 08, 2023 04:46 PM
I think this is fine if you just want to update automation records. Give it a try.
let inputConfig = input.config();
let hasImgPath = inputConfig.imgPath
let recID = inputConfig.recID;
if (hasImgPath !== null) {
let imgURL = `https://mydomain.com/${hasImgPath}`;
console.log(imgURL);
const submissionsTable = base.getTable("Entries")
await submissionsTable.updateRecordAsync( recID,
{
'PhotoURL': [{url:imgURL}]
}
);
} else {
console.log('No image attachment');
Aug 04, 2023 04:12 PM
I don't know scripting so I can't help you there, but if you want an extremely easy no-code way of doing this, you can do this with Make's webhooks. No scripting nor coding required. Just have Make receive the webhook, and then do whatever you want to do in Airtable after that.
If you need help navigating the Make interface, I created this basic navigation video, along with some links to a few other Make resources.
Aug 04, 2023 08:09 PM
Hi @mrcard ,
Each field has a different data type, so refer to the documentation.
multipleAttachments
Cell write format
TYPEDEF
Array<{
url: string,
filename?: string,
}>
Cell values & field options - Airtable Scripting
In the case of your script, it looks like this
await table.updateRecordAsync(record, {
"PhotoURL" : [{url: imgURL}]
})
Aug 08, 2023 09:23 AM
Thank you Sho for your response. I am able to update the path now but unfortunately it is not on the current record being processed in the automation, rather the last record with an empty imgPath field.
How might I point it to the current record being processed by the automation?
Below is my script:
let inputConfig = input.config();
let hasImgPath = inputConfig.imgPath
let recID = inputConfig.recID;
if (hasImgPath !== null) {
let imgURL = `https://mydomain.com/${hasImgPath}`;
console.log(imgURL);
const submissionsTable = base.getTable("Entries")
const submissionsQuery = await submissionsTable.selectRecordsAsync({fields:["ImgPath", "PhotoURL"]})
let record = submissionsQuery.records[0].id;
console.log(`record:${record}`);
await submissionsTable.updateRecordAsync( record,
{
'PhotoURL': [{url:imgURL}]
}
);
} else {
console.log('No image attachment');
}
Aug 08, 2023 04:46 PM
I think this is fine if you just want to update automation records. Give it a try.
let inputConfig = input.config();
let hasImgPath = inputConfig.imgPath
let recID = inputConfig.recID;
if (hasImgPath !== null) {
let imgURL = `https://mydomain.com/${hasImgPath}`;
console.log(imgURL);
const submissionsTable = base.getTable("Entries")
await submissionsTable.updateRecordAsync( recID,
{
'PhotoURL': [{url:imgURL}]
}
);
} else {
console.log('No image attachment');
Aug 09, 2023 06:56 AM
Thanks so much for your continued help. For some reason, the script is not finding the record as the ID that gets passed into the script is not the same as the record in the table:
My Table:
Script:
Automation:
I also tried just using the ID (autonumbering) field to locate the record but for some reason that is not recognized by the script when including it in the Input variables.
Aug 09, 2023 01:12 PM
Updated input variables to point to correct action steps and Sho's answer above is working. Thanks again!