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 09, 2021 12:06 PM
Hi Airtable community,
I’m a complete novice at scripting, so bear with my ignorance here.
I have a table with three fields: Email, Converted Email, and a Button.
I want the button to trigger a script that encodes whatever’s listed in the Email field to base 64 and push it to the Converted Email field.
I’ve gotten this to work so far using this script:
let table = base.getTable("EncodeEmails");
let record = await input.recordAsync("Converting record", table);
let b64 = btoa(record.getCellValueAsString("Email"));
output.inspect(b64);
This outputs the base 64 converted email in the scripting app, which is great. But I want that result to push to the Converted Email field in the record. I’m not quite sure what to do next.
This is what I have so far, pieced together using examples:
let table = base.getTable("EncodeEmails");
let record = await input.recordAsync("Converting record", table);
let b64 = btoa(record.getCellValueAsString("Email"));
let recordId = b64.record[0].id;
await table.updateRecordAsync(recordId, {
"Converted Email" : b64,
})
But I get this error when I click the button in the record to trigger the script:
TypeError: Cannot read property '0' of undefined
at main on line 4
I think I’m almost there, I just can’t figure out how to get it to update the record. Greatly appreciate any help!
Solved! Go to Solution.
Jun 09, 2021 01:00 PM
Don’t rely on the output of b64
to determine the recordId
to update if you already have the record
defined. Your recordId
should simply be:
let recordId = record.id
Jun 09, 2021 01:00 PM
Don’t rely on the output of b64
to determine the recordId
to update if you already have the record
defined. Your recordId
should simply be:
let recordId = record.id
Jun 09, 2021 01:05 PM
that was it! Thank you so much