I have tried a try-catch approach that whenever an option is not found in a single-select field due to typographical errors it will try to find a suitable option from the list of options in a single-select field. I have tested this approach in a scripting app and it works. However, when I applied this to a scripting action in Airtable automation, the field did not accept the value even if works in the scripting app. I don’tqu
Here is the coding block in question:
salesChannel={name: "value"}
try{
if(salesChannel){
await table.updateRecordAsync(recordId, {
"Sales Channel": salesChannel
});
console.log("Updated sales channel")
}
} catch (error){
console.log(channelOptions)
let salesChannelName = salesChannel.name.replace(/\s/g, '').toLowerCase()
console.log(salesChannelName)
let alternativeChannel = channelOptions.filter(channel => {
let channelName = channel.name.replace(/\s/g, '').toLowerCase()
return channelName.includes(salesChannelName)
})
salesChannel = null
if (alternativeChannel.length > 0){
salesChannel = {name:alternativeChannel[0]["name"]}
}
console.log(salesChannel)
console.log(recordId)
try{
await table.updateRecordAsync(recordId, {
"Sales Channel": salesChannel
});
console.log("Updated sales channel")
} catch(error){
console.log(error)
console.log("Cannot Updates Sales channel from the alternatives")
}
}