cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

Change the name of attachments via attachment control

Hello there,

 

I've created an app where our engineers have to fill in a survey. The survey exists of multiple subjects and every subject has a number of questions and multiple pictures.

The attachment control in PowerApps is great for this purpose. They can fill in the survey and upload all the data and pictures to SharePoint in a list with the pictures as attachments.

 

What I need is the pictures to show up in a specific order. At the end a document is created (HTML) with the answers to the questions per subject in a particular order. The pictures they took per subject has to follow that order.

 

I think it must be very easy to do by renaming the pictures / files to a name that starts with the same number as the survey subjects. Then it's easy to filter the pictures in multiple gallery's and show them in HTML via dynamic tables.

 

But I need some help to figure out on how to define the filename of the pictures. 

Thanks in advance for helping me out.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Hi @Anonymous,

 

Thanks for feedback.

Per my certain test, I am afraid that it would be not possible to change the file name via attachment control.

There is a similar request on PowerApps Ideas Forum, please vote and comment the idea at here, PGs will take hot ideas into consideration first:

https://powerusers.microsoft.com/t5/PowerApps-Ideas/Naming-an-attachment/idi-p/142000

Thanks for your understanding and cooperation.

 

Best regards,

Mabel

 

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Highlighted
Community Support
Community Support

Hi @Anonymous,

 

Thanks for feedback.

Per my certain test, I am afraid that it would be not possible to change the file name via attachment control.

There is a similar request on PowerApps Ideas Forum, please vote and comment the idea at here, PGs will take hot ideas into consideration first:

https://powerusers.microsoft.com/t5/PowerApps-Ideas/Naming-an-attachment/idi-p/142000

Thanks for your understanding and cooperation.

 

Best regards,

Mabel

 

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted

Hi @v-yamao-msft 

 

Is there any way araound to the file re-naming during upload with powerapps into the SP List?

 

thanks,

pytbyt

Highlighted

Hi,

 

There's a workaround:

1. Put the following formula on the OnAddFile, OnRemoveFile and OnUndoRemoveFile of your attachment control:

ClearCollect(AttachmentCollection;{AbsoluteUri:" ";DisplayName:" ";Id:" ";Name:" ";Value:" "});;Collect(AttachmentCollection; DataCardValue21.Attachments);;RemoveIf(AttachmentCollection;Id=" ") [You are creating the AttachmentCollection which will have the data to be uploaded onto your SP List; Then you are collecting the data you have in your attachment control; then you are removing the blank record you used to create the collection]

P.S.: I am using PowerApps in Portuguese, so you might have to change some ";" for it to work.

 

2. Change the Update property of the DataCard which contains the attachment control to AttachmentCollection (it must recognize it as a collection)

 

3. All you have to do now is create a mechanism to change the "DisplayName" and "Name" fields on your collection before submitting the form.

N.B.: the changes you make in the collection will not be reflected in the attachment control so you need to take this into consideration in order to create a functional solution.

Highlighted

Hi

Could you please explain a bit more clearly with screen shots...

 

Thanks in advance,

Mary

Highlighted

@leonardosouza  This worked perfectly in my scenario, but the OnRemoveFile and OnUndoRemoveFile controls does not work now.

I've added additional Patch function after your code (only to OnAddFile control) to automatically rename attachments after submitting the form (and this works perfectly):

 

 

ClearCollect(AttachmentCollection,{AbsoluteUri:" ",DisplayName:" ",Id:" ",Name:" ",Value:" "});Collect(AttachmentCollection, DataCardValue4.Attachments);RemoveIf(AttachmentCollection,Id=" ");Patch(AttachmentCollection,Last(AttachmentCollection),{Name:Concatenate('Host Name Edit'.Text,"_",'User Edit'.Text,".jpg"),DisplayName:Concatenate('Host Name Edit'.Text,"_",'User Edit'.Text,".jpg")})

 

 

in my scenario I'm changing default name of taken photo to "[host name]_[user].jpg"

any ideas how to fix OnRemove and OnUndo controls?

 

PS. sorry if you have to change back comas to semicolon 😉

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (9,598)