Sep 18, 2023 06:50 AM - edited Sep 18, 2023 09:10 AM
Hello,
We are struggling to extract the first image of a column called "photos" then re-upload it in another column.
We tried to do it by having a formula to extract the first attachment url (which is working) :
(IF(BLANK(photos), "", MID(photos, FIND("(", photos) + 1, (FIND(")", photos) - 1) - (FIND("(", photos))))
Then, using the following automation to upload it in our target column "1st_photo" :
=> WHEN a record match conditions "photos" isn't empty THEN update the column "1st_photo" using the url from the formula column as input. However, this automation isn't working
I guess the issue come from the attachment url. Do you have any idea to handle it ?
Does it require a script ?
Thank you very much !
Solved! Go to Solution.
Sep 19, 2023 02:14 AM
This can be done in one automation.
First add a single line text field that records the list of download URLs from the automation.
Then add the following formula field that extracts the first URL from the list of download URLs
REGEX_EXTRACT({Download URLs},"(^[^, ]*)((, )|$)?")
In the Automation settings
1. Trigger when the attachment is updated
2. Update the download URL list
3. Delay script 1 second (as it sometimes fails without delay)
function delay(ms) {
var limit = new Date();
limit = limit.setMilliseconds(limit.getMilliseconds() + ms);
while ((new Date()) < limit) {
// do nothing
;
}
delay(1000); //delay 1 second
*This script is shared by this community
4. Upload with extracted URLs
This is updated even if the first attachment is changed by manual sorting.
Sep 19, 2023 02:12 PM - edited Sep 19, 2023 02:15 PM
Thank you for your advices @Sho !
I followed the steps but it was too buggy, even when I was using the delay script set to 3 secondes the automation was very unstable and the 1st photo wasn't uploaded in many cases.
I found another easy way to handle it through an easy Make automation.
1 - Search for record (not having the 1st picture uploaded in your target column). You can create a view on Airtable to filter only the record you want to update.
2 - Update the record by mapping the attachement fields (array)'s first element into your target column.
Sep 18, 2023 10:18 PM
Hello @Tony,
Unfortunately, URL for the attachment field that can currently be referenced in the formula is an invalid URL.
However, various URLs and other values can be retrieved from automation.
"Expiring Download URL" can be used to upload to other Attachment fields.
Sep 19, 2023 12:41 AM
Thank you for the reply @Sho.
So if we want to extract the first attachment. I guess the only solution would be to run a sript or an automatisation with Make ?
Sep 19, 2023 02:14 AM
This can be done in one automation.
First add a single line text field that records the list of download URLs from the automation.
Then add the following formula field that extracts the first URL from the list of download URLs
REGEX_EXTRACT({Download URLs},"(^[^, ]*)((, )|$)?")
In the Automation settings
1. Trigger when the attachment is updated
2. Update the download URL list
3. Delay script 1 second (as it sometimes fails without delay)
function delay(ms) {
var limit = new Date();
limit = limit.setMilliseconds(limit.getMilliseconds() + ms);
while ((new Date()) < limit) {
// do nothing
;
}
delay(1000); //delay 1 second
*This script is shared by this community
4. Upload with extracted URLs
This is updated even if the first attachment is changed by manual sorting.
Sep 19, 2023 02:12 PM - edited Sep 19, 2023 02:15 PM
Thank you for your advices @Sho !
I followed the steps but it was too buggy, even when I was using the delay script set to 3 secondes the automation was very unstable and the 1st photo wasn't uploaded in many cases.
I found another easy way to handle it through an easy Make automation.
1 - Search for record (not having the 1st picture uploaded in your target column). You can create a view on Airtable to filter only the record you want to update.
2 - Update the record by mapping the attachement fields (array)'s first element into your target column.
Sep 19, 2023 04:11 PM
Was it no work?
I had no problem testing with light images. It seems to fail if the upload takes too long.
If it fails in one automation, it might be better to split it into two.
Anyway, MAKE would be a sure thing.
Sep 29, 2023 01:04 PM
hello @Sho how to extract first image from multiple image attachments in airtable in same table I want only 1st pic shown in the column from multiple image attachements
Sep 29, 2023 09:08 PM
Hello @Fazia_Fayyaz,
One automation was unstable, so two should be fine.
In addition to the Attachment field, add the following four additional fields
"Attachment IDs" single-line string field
"Attachment URLs" single-line string field
"First Attachment ID" formula field with the formula
REGEX_EXTRACT({Attachment IDs},"(^[^, ]*)((, )|$)?")
"First Attachment URL" formula field, with the formula
REGEX_EXTRACT({Attachment URLs},"(^[^, ]*)((, )|$)?")
The two automations are set up as follows
Automation1 Setting
It will be trigger each time the Attachment field is updated.
How to get Attachment's ID and URL is to change Display properties.
Automation2 Setting
Automation2 is triggered only when the First Attachment ID is changed.
Give it a try.