Extract the link for last attachment added

Hi,

I can’t seem to figure out what I’m doing wrong. I’m trying to pull the link for the last attachment added and the only way I thought to try was using Regex. I tested in regex101 here: regex101: build, test, and debug regex

I’m using this in a formula field: REGEX_REPLACE({Image URLs},'.*\\((?=[^(]*$)','') and just get an error.

I’m trying to extract from an attachment field:

190423-LMOps005Pool-Fitness0130_blue.jpg (https://dl.airtable.com/.attachments/cad9e1ef16011261083de0d3af0f372e/dbf5c759/190423-LMOps005Pool-Fitness0130_blue.jpg, 190423 LMOps005Pool Fitness0130.jpg (https://dl.airtable.com/.attachments/34893e2547f354b5377bd0ca0d39d118/e6877e1d/190423LMOps005PoolFitness0130.jpg

Hi @Brent_del_Rosario
I am sorry I am not up to speed on REGEX maybe that formula is only good if there is only a single attachment. But if you just want to see the URL, this script will output all of the attachment details for a record.

let table = base.getTable("Table 1");
let record = await input.recordAsync('Select a record to use', table);
let attachments = record.getCellValue('Attachments')
output.table(attachments)

It should not be too hard to expand on and just get the last URL if that is what you want and you could go further to have it update a text field.

1 Like

You should be aware that even if you get the formula to work, it will not work come November.

I’ll see if I can pull from that and use it in an automation.

Thanks for the heads up! I’m using this for approving edits and suggested images to move from a Preview field to an Image field. We then use a tool to do a datamerge in Indesign. Expiring links won’t really apply to us as we’ll only need to download once.

The issue isn’t just expiring links. The links extracted using formula fields will be invalid. In order to get the expiring link, you will need to use a different method, such as scripting or a 3rd party tool.

Yikes. I guess we’ll just revert to adding attachments via links in our DAM. I’ve been meaning to build some workflows around that anyway. Thanks!!

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