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 / Remove an attachment f...
Power Apps
Unanswered

Remove an attachment from attachment control if that is an unacceptable file type

(0) ShareShare
ReportReport
Posted on by 36

 

Hello,

 

I am experiencing an issue with PowerApps - Attachment Control.

I have created an app using a SharePoint list and I used a form control. My requirement is to allow only to upload .pdf and .xlsx file types in the attachment control.


I used below functions in "OnAddFile" property of attachment control.

 

 

If(
 Not(
 EndsWith(
 Last(Self.Attachments).Name,
 ".pdf"
 )
 ) And Not(
 EndsWith(
 Last(Self.Attachments).Name,
 ".xlsx"
 )
 ),
 Notify(
 "Only .pdf and .xlsx files are allowed",
 NotificationType.Error
 );
 RemoveIf(Self.Attachments, Name = Last(Self.Attachments).Name);
)

 


In this way, attachment adds to the form control, even if it is not an acceptable file type. But when trying to upload another attachment, previously uploaded incorrect file removes.


I need to stop adding that incorrect attachment to the form control. I used Reset() function as well. But it resets the entire
attachment control. I need to remove only the unacceptable attachment.


Please can someone help me with this?

Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at

    Hi @Nipuni ,

    Unfortunately, you cannot do this (I have been down this track before) - you have already stated the only solution which is to reset the control which deletes all unsaved attachments. For some reason the RemoveIf wants to remove the second last attachment - this does not work either

    If(
     !EndsWith(
     Last(Self.Attachments).Name,
     "pdf"
     ),
     Remove(
     Self.Attachments,
     Last(Self.Attachments)
     )
    )

     

  • Nipuni Profile Picture
    36 on at

    @WarrenBelz Your answer is useful for me. Thank you very much for your reply. 

  • divyasingh Profile Picture
    8 on at

    suppose we want only a specific file format to get added in our attachment control and rest to not even get added over there, can we achieve this, can we restrict on add file property of attachment to accept only .pdf or abc.pdf names anyway, w/o any extra buttons just by setting up it on on add file or on remove file property

  • WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at

    @divyasingh ,

    OnAddFile

    If(
     Lower( 
     Last(
     Split(
     Last(Self.Attachments).Name,
     "."
     )
     ).Value
     ) <> "pdf",
     Notify(
     "Only PDF files allowed",
     NotificationType.Error
     );
     Reset(Self)
    )

      

  • divyasingh Profile Picture
    8 on at

    Whta if i want to directly remove file from my attachment control RemoveIf(myFiles,LookUp(myFiles(Attachments_Required.Attachments),Name = "ABC.csv" || Name = "CDE.csv"))

  • WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at

    @divyasingh ,

    Not possible with code as far as I know

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 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard