cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper I
Helper I

How to check if the email attachment in sharepoint is already exist then it will save with another name?

Dear all,

 

Firstly, I would like to say hi to all of you.

 

Currently the scenario in my company: when an email with xml attachment send to an outlook mailbox. It will get this attachment and save to my sharepoint folder. I have created the flow as images below and works well.

flow_1.JPG

 

flow_2.JPG

 

But we have problem that if someone suddenly send the same file after a while then the file in my sharepoint will be overwrite. Therefore, my concern is that: how can we create a flow that after the attachment email arrive, it will check if the file is already exist then it will create another file name with date suffix in my sharepoint (example: a.xml, a-date.xml)? 

 

 Because I'm so new with this technology and my programming skill is not good enough so I seek for your help for our solution. Thank you for your reading my post and I will look forward to hear from you. 

 

Stay safe and healthy all.

1 ACCEPTED SOLUTION

Accepted Solutions

@Blader1989 

See my screen shots below.  Note that in the Create file action that is used when the file already exists, I am prepending the filename with the current date and time - you can substitute whatever you want there.  Also, I didn't take the file name without the extension and add something to the end and then add the file extension back.  I didn't do that because I didn't want to complicate the solution.  To do so, I would need to use a split() action to break the file name apart.  If you need that, just let me know and I'll add it in.

CF1.jpgCF2.jpgCF3.jpg

 

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

View solution in original post

6 REPLIES 6
Super User III
Super User III

@Blader1989 

Before creating the file, use a Get files (properties only) action.  Use an OData filter query in the action to find only files with a certain name.  If it returns any files, you know that the file already exists and you need to change the name of the file that you are attempting to create.

Let me know if you need an example.

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

Dear @ScottShearer

 

Thank you for your reply. Can I have your example? It would be a lot of help for me.  

@Blader1989 

See my screen shots below.  Note that in the Create file action that is used when the file already exists, I am prepending the filename with the current date and time - you can substitute whatever you want there.  Also, I didn't take the file name without the extension and add something to the end and then add the file extension back.  I didn't do that because I didn't want to complicate the solution.  To do so, I would need to use a split() action to break the file name apart.  If you need that, just let me know and I'll add it in.

CF1.jpgCF2.jpgCF3.jpg

 

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

View solution in original post

Dear @ScottShearer

 

Thank you for your wonderful magic. I have applied your practice and worked well. 

 

But I have 2 problem and still need your help. 

 

1/ The time of date in this image

flow_1.JPG 

How can we convert the time to our regional? We are in GMT+7 - Hanoi time.

 

2/ How can we remove the email signature just get the specific attachment file? Our finance team just only want to get the XML attachment file from user.

flow_2.JPG

@Blader1989 

You can use a Convert time zone action to convert UTC to your local time.  Refer to the output of this action rather than utcNow() when naming the file.  Select the date format of your preference.

image.png

To limit what you do only to XML files, add another condition and put your existing condition inside of it (on the true side).  See my example below.  I am converting the file name t lower case and testing if it ends with xml.  If it does, then I go onto the second condition where you actually create the files in SharePoint.

image.png

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

Dear @ScottShearer

 

I have followed your example for remove signature but my  sharepoint is not create the xml file even the flow test successfully

 

 

signatu.jpg

Where did I go wrong? Thank you.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

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!

Users online (7,958)