Help

Re: Add only the latest attachment through automation

Solved
Jump to Solution
1928 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Tim_Asklof
4 - Data Explorer
4 - Data Explorer

Hi,

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:
Skärmavbild 2022-05-13 kl. 17.48.53

Here is the current action:
Skärmavbild 2022-05-13 kl. 17.48.30

1 Solution

Accepted Solutions
Alexey_Gusev
13 - Mars
13 - Mars

Hi,
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.
so:

const single=input.config().urls.pop();
output.set(‘url’,single);

that’s how similar setup looks like:
image

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.

See Solution in Thread

4 Replies 4
Alexey_Gusev
13 - Mars
13 - Mars

Hi,
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.
so:

const single=input.config().urls.pop();
output.set(‘url’,single);

that’s how similar setup looks like:
image

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.

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.