Announcements
is it possible to set the color of items added to the Attachment Control in a canvas app. For example, if the item attached is a DOCX or XLSX set the color to RED otherwise set color to BLUE.
thanks,
Rtc
@rcapone
I don't think this is possible, at least I couldn't find a way to do it. You could use a Label to notify users instead, eg
CountRows( Filter(attach.Attachments, ".jpg" in Name))
if the color can't be changed is there a way to have any attachments having DOCX or XLSX extensions not allowed to be added?
I came across this post which was helpful. When the code below is put in the OnAddFile of the Attachment Control; however, it only tests the last attachment - which falls short when multiple files are attached.
If( Right( Last(Self.Attachments).Name, 3 ) <> "pdf", Notify( "You can only attach PDF files", NotificationType.Error ); Reset(Self) )
the other option is there a way to allow only 1 file at a time to be added to the Attachment Control?
thanks
I think this solution may do what you need?
https://powerusers.microsoft.com/t5/Building-Power-Apps/Allow-only-some-file-types-as-attachments/td-p/469316
The solution checks for PDF but you can change to DOCX and XLSX. The author uses a label (visible only when the condition is triggered) to notify users they cannot save. Then, the Save button is made invisible if the label is visible.
it tests the First attachment which was similar to the code I found in the link below was testing the Last attachment.
https://powerusers.microsoft.com/t5/Building-Power-Apps/PowerApps-Enforce-File-Type-on-the-Attachment-Control/m-p/631573/highlight/false#M200259
I used the Count approach you initially posted.
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.
Congratulations to our 2026 Super Users!
Congratulations to our 2025 community superstars!
These are the community rock stars!
Stay up to date on forum activity by subscribing.
11manish 505
WarrenBelz 502 Most Valuable Professional
Haque 324