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?
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.
Solved! Go to Solution.
@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?
@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.
The next step would be to create a compose and extract the sequence number from the output body of the HTTP request action.
Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.
Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!
Check out the community blog page where you can find valuable learning material from community and product team members!