cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Jack08
Regular Visitor

How do stop MS Form file attachment name from being appended with "anonymous X"?

When a user attaches a file to our form that file named "Test Document 1" is renamed to "Test Document_anonymous 1".  Power Automate is sending the file via email and to a SharePoint site. It has the same new name in both places. How do I get it to send the file with its original name?

1 ACCEPTED SOLUTION

Accepted Solutions
abm
Super User
Super User

Hi @Jack08 

 

Thanks for the screen share. So the expression for the filename we used is as follows:


concat(first(split(items('Apply_to_each_3')['name'],'_')),'.',last(split(items('Apply_to_each_3')['name'],'.')))

 

Then for the content 

 

body('Get_file_content')?['$content']

 

Finally mapped the filename and content under the array variable and Add attachment SharePoint action step.

 

Hope it make sense.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

View solution in original post

11 REPLIES 11
abm
Super User
Super User

Hi @Jack08 

 

Could you post a screenshot of your flow? You could use a replace expression to remove "_anonymous 1' from the filename.



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials
Jack08
Regular Visitor

Hi abm. Thanks for your response!  Below is the screenshot of the flow.

 

screencapture-make-powerapps-environments-Default-0eb48825-e871-4459-bc72-d0ecd68f1f39-logicflows-2021-06-21-14_04_13.png

Hi @Jack08 

 

Thanks for your reply. So what you need to do is add an expression like below where you mapping the filename.

 

first(split('YourFilenameDynamicVariable', '_'))

 

This will get you just the filename as 'Test Document'

 

If you want the extension then you need another split as well using '.' The use the last() expression to get the extension

 

last(split('YourFilenameDynamicVariable', '.'))

 

Finally using concat() expression you can get the full filename with extension.

 

concat(first(split('YourFilenameDynamicVariable', '_')), last(split('YourFilenameDynamicVariable', '.')))

 

Thanks

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials
Jack08
Regular Visitor

Hi abm, Thank you for your support with this. I am pretty new to Automate and I am not able to figure out where / how to put the lines of code you provided. (we would prefer the version that includes the file extension).  Can you provide any more details on how that is done? Thanks so much!!

abm
Super User
Super User

Hi @Jack08 

 

Thanks for the screen share. So the expression for the filename we used is as follows:


concat(first(split(items('Apply_to_each_3')['name'],'_')),'.',last(split(items('Apply_to_each_3')['name'],'.')))

 

Then for the content 

 

body('Get_file_content')?['$content']

 

Finally mapped the filename and content under the array variable and Add attachment SharePoint action step.

 

Hope it make sense.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials
Jack08
Regular Visitor

Thank you Ajith!  You have been an amazing help. Incredibly knowledgable.I never would have been able to figure that out on my own.  Thank you!

MariusHz
Regular Visitor

It was really instructive this answer, thanks!! but I still have an issue when trying to open the attached files in the e-mail. I receive a message like the following (I think in the file content I ain't getting the correct data.

Error message:

"Excel cannot open the file 'xxxxx.xlsx' because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file".

 

Could you help?

Hi @MariusHz 

 

Could you please create a new thread and let me know?

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials
sespinac
Regular Visitor

Hi! I used this solution of the concat expression and it works amazingly when I upload one document, but if I upload multiple documents, I get an error and the flow fails... Any suggestion on how to overcome this? Thanks!

Hi @sespinac 

 

Could you please create a new thread for this? Also post a screenshot of your flow. I will have a look.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials
sespinac
Regular Visitor

Thank you! I just found out what the problem was. But thanks anyway for responding!

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (3,094)