Help

Re: Moving attachments

4030 1
cancel
Showing results for 
Search instead for 
Did you mean: 
Matthew_Hilshor
5 - Automation Enthusiast
5 - Automation Enthusiast

There are so many amazing things Airtable can do… why can’t I figure out how to move attachments?
I have a table and I have a team of employees that document images of damages they see in real life at the museum I work at. When that same team access’s this table they look at the attachment field see what has been noted as damaged the day before and then fix that damage in real life. Once the damage has been fixed I want them to either move that attachment to a “fixed” attachment field or put an automation so that they can rename the image as “fixed” and it will then move to a “fixed” attachment field. This very simple function doesn’t seem to exist?! Or am I missing something?

10 Replies 10

Hi @Matthew_Hilshorst

I’m not sure I’ve ever seen a request quite like this one. I think a possible solution might be to have a separate table for attachments, where you have a single record per attachment, and those attachment records are linked to some associated project. This attachments table could have a “Status” field where you could mark an attachment record as being “Fixed” or “Needs Fixing”, etc.

It might require a little more overhead in terms of work linking attachments and number of overall records in your base, but it’s what comes to mind as a potential solution.

Otherwise, I’m not sure there’s a clean way to move selected attachments out of one attachment field and into another – this is why it might benefit you to have discrete records per attachment.

If you click once into an Attachment field, you can press command-C (or control-C) on your keyboard to copy all of the attachments in that field. Then you can click into another Attachment field, and press command-V (or control-V) to paste the attachments.

However, that’s not really an ideal solution. Ideally, you would want to setup your attachment structure differently, like @Jeremy_Oglesby recommended above.

Thanks for the quick reply. That’s not a bad suggestion. It seems like a lot of work to list them all separately. We have days where there will be dozens of images of damage. I need to make sure that images that aren’t worked on stay on the damage field and the fixed ones moved to a fixed field.
It seems so simple but it has alluded me for years (going on 5 years using Airtable).

Thanks for your reply. I have done the copy paste approach but the paste function either erases what is already in the attachment field when the new group of photos is pasted or I have to go through and delete all the images I didn’t want copied. There seems to be no way to copy a single image and paste it or drag it over to the field in which I need to put it.

Each attachment has its own URL. You can mimic the “appending” of attachments to an existing attachment field by using Airtable’s Automations. You can put a comma in between the old Attachment URL and the new Attachment URL. (But note that this will essentially “re-upload” the old attachments along with the new attachment, so you will lose any annotations or comments that you’ve added to the old attachments.)

If you just want to pull one attachment out of a field to append it to another field, that would be slightly more tricky. You would need to know the URL of the individual attachment ahead of time. Once you get that URL, you can use automations just like above. (Note that you would still lose the annotations or comments for that attachment.)

Ideally, if you’re looking for a low-code/no-code way of doing this, I would highly recommend using Integromat to do this. This is really the easiest way of doing it — it can loop through all the attachments in an attachment field, and can move individual attachments or all of the attachments into another field. (You’d still lose the annotations or comments.)

But I think that @Jeremy_Oglesby 's solution is probably best — if you setup your database tables so that there is only 1 attachment per child record (and then link attachments to a parent record), then you have a lot more flexibility without much downside.

p.s. I am a professional Airtable consultant and a Registered Integromat Partner, and the Integromat link contains my personal referral code.

Hi @Matthew_Hilshorst - I managed to figure out a way to do this, based on your suggestion of renaming the image to “fixed”. Here’s my set up:

Screenshot 2021-01-14 at 20.53.19

So, two attachment fields, the original and “Fixed” and a last modified field (actually you don’t need this, but helped to understand what was going on). I then have an automation:

Screenshot 2021-01-14 at 20.55.36

The trigger is based on the original Attachments field:

Screenshot 2021-01-14 at 20.56.18

The record is updated when the attachment name is changed, so this is sufficient to kick off the automation. The script in the automation is:

let inputConfig = input.config();
let table = base.getTable('Table 4'); 
let query = await table.selectRecordsAsync()
let record = query.getRecord(inputConfig.record);
let attachments = record.getCellValue('Attachments');
for (let attachment of attachments) {
    if(attachment.filename.toLowerCase() == 'fixed'){
        table.updateRecordAsync(record, {
            'Fixed': [...record.getCellValue('Fixed'), {url: attachment.url}]
        });
        let index = attachments.indexOf(attachment);
        attachments.splice(index, 1);
        table.updateRecordAsync(record, {
            'Attachments': attachments
        })
    }
}

and I’ve got an input variable, which captures the record that has been updated so that the script can use this:

Screenshot 2021-01-14 at 20.58.06

For script enthusiasts, a quick explanation:

  • the script gets the updated record and grabs the contents of the Attachment fields (one or more attachments)
  • we loop through this set of attachments and if any have a filename of ‘fixed’ or ‘Fixed’, then the script will copy that attachment into the “Fixed” field and remove the same attachment from the original Attachments field.
  • We have to use the spread operator (...) on the “Fixed” field so we add to rather than overwrite
  • We then use splice to remove this attachment from the original attachments array, then update this field with the new reduced array.

Really great, solution, @JonathanBowen! I didn’t realize we had access to attachment.filename in scripts.

Depending on the OP’s needs for filenames, I might make one small suggestion to check for the presence of the string ‘fixed’ inside the filename, as opposed to direct equivalence, so that the option is still there to have distinct file names, but append them with “_fixed”, for example.

So on line 7 of the script,

if(attachment.filename.toLowerCase().includes('fixed')){

@Jeremy_Oglesby - yes, that makes a lot of sense, good suggestion!

Jennifer_Goodwi
4 - Data Explorer
4 - Data Explorer

You can also do this: http://somup.com/c0nQY0xJWZ