Creating unique file names in a SharePoint library

Quick Tip

The ability to send file attachments (such as uploaded files and generated documents) through Microsoft Power Automate is only available to organizations on our Pro, Team and Enterprise plans.

When sending uploaded files to a SharePoint library, you must ensure that each file has a unique name. SharePoint document libraries do not allow two documents with the same name. If any two files have the same name, one of those files will be deleted.

To ensure that each file sent to SharePoint has a unique name:

  1. Create a new flow. Search for Cognito Forms in the services list and then select a trigger.

  2. Add a step using the Data Operation > Compose action. Select the Name field value from the Dynamic content as the input. If you have multiple File Upload fields, they will be listed in the order that they appear on your form.

  3. After selecting the Name value, the flow will automatically put this step into an Apply to each operation so that each uploaded file is sent to SharePoint. Select Add an action at the bottom of this box, and choose SharePoint > Create file.

  4. Choose the Site Address and Folder Path for the destination folder in SharePoint. Set the File Content option to Content from the dynamic content list. If you have multiple File Upload fields, the Content value for each field will be listed in the order that it appears on your form.

  5. For the File Name option, select the Id value from the dynamic content list. This value will include the form Id and entry number in the file name to ensure that each file has a unique name.

  6. Include another field from the form (such as Name) to more easily identify who submitted the document.

  7. Finally, add a period (".") to the File Name option after the Id value. Then, switch to the Expression editor and add the following function: last(split(outputs('Compose'),'.'))

Make sure to save your flow, and test it out by submitting an entry with an uploaded file to the form.

Support