How do I get a URL for attachments so that it pulls up the attachment view IN Airtable?

What I’m looking for is to be able to send out a URL to collaborators that will bring them to the attachment view window inside Airtable so that they can view my attachment and leave comments.

I have tried assigning a trigger & action in automations like this:
Screen Shot 2021-06-25 at 7.17.48 PM
(“Drafts” is what I named the attachment field") but all this does is open an image of the attachment in your browser. It does not open Airtable.

PLEASE HELP!

The URL pattern for having a particular attachment opened such that someone could comment on it is as follows:

https://airtable.com/table_ID/view_ID (optionally)/record_ID/field_ID/attachment_ID

As far as I know, the only way you’d be able to get both the field ID and the attachment ID is with a script. Since you’re already using an Automation, assuming your base is on a Pro Workspace, this isn’t a hinderance:

Before the automation step you have now, add a Run a script action step that has two input variables (add input variables on the left side of the screen): recordURL which should be the trigger record’s URL, and attachmentIds which should be the value from the attachment field as a “List of… ID” (as opposed to a list of URLs or list of names).

Then add the following script (renaming the Attachment field as necessary):

let {recordURL, attachmentIds} = input.config()

let attachmentFieldName = "Attachments"

let recordInfo = {
    tableId: recordURL.split("/")[3],
}

let fieldID = base.getTable(recordInfo.tableId).getField(attachmentFieldName).id

let constructedURLs = attachmentIds.map(id => {
    return recordURL + "/" + fieldID + "/" + id
})
output.set("constructedURLs", constructedURLs)

Use the output of the script in your message to collaborators

3 Likes

This topic was solved and automatically closed 15 days after the last reply. New replies are no longer allowed.