A file with the same name is currently being saved to this site error in Power Automate

In this Power Automate tutorial, we will see how to fix the error ‘A file with the same name is currently being saved to this site‘.

Recently, when creating a Power Automate flow to generate a Word document in the SharePoint library based on the SharePoint list, I encountered an error stating that A file with the same name is currently being saved to this site.

Power Automate Error A file with the name already exists

In this tutorial, we will discuss why we encounter this error ‘A file with the name already exists’ and how we can fix this error.

A file with the same name is currently being saved to this site in Power Automate

Here, we have a SharePoint list called Order Tracking, which contains all the information related to the order. Whenever a new order is added, we will create an invoice if the Payment status is paid.

The SharePoint list contains the following columns:

Column NameType
TitleA single line of text
Customer NameA single line of text
Shipping AddressA single line of text
Order DateDate/Time
Product OrderedChoice [Laptop, Pendrive, Headphone]
QuantityNumber
Total AmountNumber
Payment StatusChoice [Paid, Unpaid, Declined]
Invoice NumberSingle line of text
Payment WithChouce [UPI, Cash, Card]
Payment DateDate/Time
InvoiceAttachment
how to prevent flow failing if file name already exists when creating a file

To create the invoice, we created an Invoice template containing properties. We will populate this Word document in the flow to add value to those properties. Once we add the properties, we will create a Word file in the SharePoint library.

After that, we convert the Word file to a PDF file and add it to the SharePoint list as an attachment.

Below, you can see the Invoice template:

how to prevent flow failing if file name already exists when creating a file in Power Automate

For the execution of the task in Power Automate, first, I have added a trigger action i.e. ‘When an item is created or modified’ to the flow. Then, provide the site address and list name.

how to prevent flow failing if file name already exists when creating a file  Power Automate

Then we check the payment status is paid; for this, I have added the condition action to the flow, like below.

how to prevent flow failing if file name already exists when creating a file Microsoft Power Automate

If the Condition is true, then we will populate the word template and map the value to the properties like below.

how to prevent flow failing if file name already exists when creating a file in Microsoft Power Automate

Next, we will create a file in the SharePoint library, for I have added a Create file action and provided the information below.

Power automate - create new file in Sharepoint in a folder that has hashtag(#) in folder name

Then I convert the Word file to pdf using the Encodian action, i.e., Convert to pdf and provide the information like below.

Microsoft Power Automate Error  A file with the name already exists

In the last step, I have added the attachment to the SharePoint list; for this, I have added the ‘Add attachment’ action and provided the information below.

 error a file with the name already exists in power automate

Now the flow is ready, and I run the flow manually and create an item in the SharePoint list.

error a file with the name already exists in Microsoft power automate

You can see the below image. flow run failed, and I encountered the error: A file with the same name is currently being saved to this site

A file with the same name is currently being saved to this site

In the next part, we will see how we can fix this error in Power Automate.

Solution: A file with the same name is currently being saved to this site error in Power Automate.

Let’s first understand why we get this error: ‘A file with the same name is currently being saved to this site’ in Power Automate.

Now, if you look at the Create file action image, here I am providing the file name as ‘Invoice Invoice Number.docx.

As it clearly stated:

  • The invoice is normal text
  • Then Invoice number is selected from dynamic content.
  • In last, we are providing the extension as .docx.

When we run the flow, the file name is coming as Invoice #009.docx. As in SharePoint, we can’t use the special characters in the file or folder name, so we need to replace these characters for creating the file in the SharePoint library.

I have used the expression below to remove the special character ‘#’ from the file name. So it replaces the ‘#’ with ”.

replace(triggerOutputs()?['body/InvoiceNumber'], '#', '')
A file with the same name is currently being saved to this site error in power automate

Now, if I run my flow, my flow runs successfully without any error.

This is how we can fix the error ‘A file with the same name is currently being saved to this site’ in Power Automate.

Conclusion

In this Power Automate tutorial, we saw how to fix the error “A file with the name already exists in Power Automate”.

You may like the following tutorials:

>