cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

Creating unique sequential file names

Hi! I've got a flow that saves an E-mail attachment in a specific folder. The attachments are received in an E-mail with the same subject name and the same attachment name (the content of the attachment is different though).

 

When I save the files in the folder I have to come up with unique sequential names, say CF#1.xls, CF#2.xls, etc. I've created an HTTP request action that counts the number of files that are already in that folder, then I've set a variable that adds 1 to that number of items and creates a unique sequential name.

 

This worked well until 2 E-mails came at the same time, ie when the second E-mail came the attachment from the first one wasn't saved yet, so I got 2 attachments with the same number and, of course, only one of them was saved.

 

Has anyone got any ideas how else this can be achieved?

 

Update:

The problem was solved by tweaking the concurrency control of the trigger as per below. This way, even if 2 E-mails come at the same time, the flow will not be triggered if there is a flow running. Hope this helps. 

 

sat_van_0-1606217394681.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Frequent Visitor

@krootz , thanks for taking time and providing details. It seems that there is an easier way with concurrency controls:

sat_van_0-1606217494399.png

 

View solution in original post

4 REPLIES 4
Solution Supplier
Solution Supplier

@sat_van , how about using $top=1&$order_by=Filename DESC in your HTTP GET request. The idea is to get the last file created, parse the number from the file, and increment that rather than using a variable?

@krootz , thanks for your response. I'm not sure I follow to be honest - probably because I'm relatively new to Power Automate. Can you explain in more details, please?

Solution Supplier
Solution Supplier

@sat_van see HTTP request below. 

$select=Name --- only fetches the field/column "Name"

$orderby=Name desc --- sorts it by filename descending order

$top=1 --- returns the 1st filename after the order by which in your case would be the file containing the last sequence used. 

odata filters.png

The next step would be to create a compose and extract the sequence number from the output body of the HTTP request action.

Frequent Visitor

@krootz , thanks for taking time and providing details. It seems that there is an easier way with concurrency controls:

sat_van_0-1606217494399.png

 

View solution in original post

Helpful resources

Announcements
PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Top Solution Authors
Users online (7,900)