Add only the latest attachment through automation


I want to be able to upload documents in one table. These documents are usually invoices and should be uploaded to the correct supplier. When I upload a new document, I want to create a new record in a different table, for each attachment that is being uploaded.

Currently, when I run it it creates a new record but the new record contains previous uploaded attachments too. How can I ensure that it is only the latest uploaded attachment that is being created as a new record?

When I bulk upload, it also creates only one record. How can I make sure that it creates one record for each attachment that is being uploaded?

Here is the current trigger:

Here is the current action:

you can apply ‘low-code’ approach. to get last element of array, use method ‘pop’.
between trigger and ‘create record’, install simple script step.
You should pass this array, as input parameter with any name (I used ‘urls’)
input parameters located in ‘input.config()’

then you should pass output element, assigning it to some variable. you can use this variable in next steps.

const single=input.config().urls.pop();

that’s how similar setup looks like:

after that, use this variable ‘url’ in further steps, as you usually do with values.

Actually, you can do the same without code by creating additional mini-table with extracting last url from array, by text formulas, and then at next step take your value. But I think solution without extra table is better.

Keep in mind that this method of extracting urls using a formula field will likely break in November when urls of attachments undergo a change.

1 Like

Yes, you are right, it probably break, But I think that’s the least of concern with November change. I think, significant part of such scripts/automations will lose their sense of existence. Some customers even can decide to change platform. Unless there will some simple and obvious way, to preserve their valuable documents, on the moment of change and later. I mean obvious for management squad, with 'User"/“Power user” level of understanding tech side.

Hi Alexey,

Thank you so much for providing this solution. Worked like a charm.

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