Help

Get expiring attachment URL!

1702 1
cancel
Showing results for 
Search instead for 
Did you mean: 
Lom_Labs
7 - App Architect
7 - App Architect

In order to assist a community member in accessing expiring URLs for their attachments, I've developed a new extension! Now, you can effortlessly retrieve the URLs of your attachments with just a click.

Just a heads up, the Airtable makes the URLs expire for security reasons. As a result, the provided URL will only remain active for ~2 hours. Please make a note of this while using the extension.

Get URL.gif

And here is the code to paste into your script extension!

 

 

const settings = input.config({
    title: "Get temporary attachment URL",
    items: [
        input.config.table("table", { label: "Table" }),
        input.config.field("attachmentField", { parentTable: "table", label: "Attachments field" }),
        input.config.field("temporaryAttachmentURLsField", { parentTable: "table", label: "Field to put URLs" }),
    ],
});

let { table, attachmentField, temporaryAttachmentURLsField } = settings;

if(attachmentField.type !== "multipleAttachments") {
    throw new Error("Attachments field must be an 'Attachments' type field");
}

if(!["singleLineText", "multilineText"].includes(temporaryAttachmentURLsField.type)) {
    throw new Error("Field to put URLs must be a single line or long text field");
}

const record = await input.recordAsync("Pick a record", table);
const attachmentsData = record.getCellValue(attachmentField.name);

if(!attachmentsData){
    throw new Error("No attachments found for this record");
}

let attachmentURLs = attachmentsData.map(attachment => attachment.url).join("\n\n");

await table.updateRecordAsync(record.id, {
    [temporaryAttachmentURLsField.name]: attachmentURLs
});

 

 

1 Reply 1
auekk2787
7 - App Architect
7 - App Architect

Works great! Thanks for this.