web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Can we capture the att...
Power Apps
Suggested Answer

Can we capture the attachments for a SharePoint list item and rename them?

(1) ShareShare
ReportReport
Posted on by 1,811 Super User 2024 Season 1
I have a form inside canvas application , where i added 2 attachment sections; one named "Picture" and the other named "CV". now i want to associate the attachments that will be uploaded to each section, by renaming the Picture attachments to Picture-[ItemID] , and renaming the CV attachments to CV-[ItemID].
 
Here is the form's sections, with 2 attachments sections added inside custom card:-
 
 
 
and I defined the Items for the Picture attachment to be :-
 
Filter(ThisItem.Attachments,StartsWith(DisplayName,"Pic"))
 
and I defined the Items for the CV attachment to be :-
 
Filter(ThisItem.Attachments,StartsWith(DisplayName,"CV"))
 
 
then on the Submit button i am capturing the attachment inside collections as follow:-
 
SubmitForm(Form1);
ClearCollect(varPicAttachemnt, DataCardValue6.Attachments);
ClearCollect(varCVAttachments, DataCardValue6_1.Attachments);
 
 
and on the form onsuccess , i can loop through the attachments as follow:-
 
 
ForAll(varPicAttachemnt,
 
Patch(Forms,LookUp(Forms,ID=Form1.LastSubmit.ID),
{
Attachments:
 
}
 
));
 
 
But i am not sure how i can rename the attachments accordingly inside the form on success? Thanks
Categories:
I have the same question (0)
  • lbendlin Profile Picture
    8,479 Super User 2025 Season 2 on at
  • johnjohnPter Profile Picture
    1,811 Super User 2024 Season 1 on at
    Thanks for the brief reply. but the link you provided is talking about how to retrieve the list item attachments ,, while my question is about how to Patch the list item with the attachments after renaming them.. thanks..
  • Suggested answer
    Michael E. Gernaey Profile Picture
    53,433 Super User 2025 Season 2 on at
    Hi,
     
    Check this out, apologies I didn't have time to find my own one or write you one but if this doesn't work let me know ad i can come back tomorrow.
     
     
  • WarrenBelz Profile Picture
    153,084 Most Valuable Professional on at
    Just noting two fundamental problems here - whichever one you patch second will overwrite the first one (there is only one attachment field in the List). Also you cannot patch attachments from a collection like that - it needs to be directly from an attachment control using Patch(FormName.Updates), so you actually need a third (you can hide it) attachment control containing a collection combining the two others.
  • johnjohnPter Profile Picture
    1,811 Super User 2024 Season 1 on at
    Thanks actually i checked this link https://stackoverflow.com/questions/77413571/how-to-change-attachment-file-name-in-power-apps before the posted my question, but it is not very related to my problem.. so how i can customize this formula from the link :-
    ClearCollect(colAttachments, DataCardValue16.Attachments);
    RemoveIf(colAttachments, Id = "");
    Patch(colAttachments, First(colAttachments), {
        Name: "invoice" & Text(Now(), "[$-en-US]yyyy-mm-dd-hh-mm-ss") & ".pdf",
        DisplayName: "invoice" & Text(Now(), "[$-en-US]yyyy-mm-dd-hh-mm-ss") & ".pdf"
    });
     
     
    into my Form onSuccess?
    Thanks
  • johnjohnPter Profile Picture
    1,811 Super User 2024 Season 1 on at
    thanks Waren,
     
    can you please provide me with some formulas i can use inside my form onsuccess?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard