Scenario
We have a Power App list form. Now we need to store uploaded list item attachments in the document library. So we created Power Automate to get attachments from list item and upload it to the document library. Now the user may upload files with the same name, and it will replace the files with duplicate names. To prevent this, we rename the file by adding a date-time tick in the file name and then uploading it to the document library.
Implementation
we need to Create a new instant flow Our trigger in Power Automate is PowerApps (V2), and we are passing file content from Power App to Power Automate as shown below screenshot:
Initialize the Variables
Now, we will set the value to the variable. So first, set the below expression in value for the FileName variable.
set the below expression in value
Filename:-substring(triggerBody()[‘file’][‘name’],0,lastIndexOf(triggerBody()[‘file’][‘name’],’.’))
Fileextension:-last(split(triggerBody()[‘file’][‘name’],’.’))
set the below expression in value
Currentdatetime:-formatDateTime(utcNow(),’ddmmyyyyhhmmss’)
Newfile:- concat(variables(‘FileName’),’_’,variables(‘Currentdatetime’),’.’,variables(‘FileExtension’))
When we use Create File action to upload a document in the document library, use the NewFile variable for File Name.
So, this is how we can append the date time tick in the file name using Power Automate. we can get the details in the SharePoint list.
Hope this article will be helpful for you.
For any Help or Queries Contact us on info@crmonce.com or +918096556344