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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Attachment Control Ite...
Power Apps
Unanswered

Attachment Control ItemFill

(0) ShareShare
ReportReport
Posted on by 1,146

Thank you for taking the time to read my question.

I want to let the user know that I only want them to attach pictures using the Attachment control in my app. I can disable my save button if the result of the following formula is greater than 0 but I also want to change the ItemFill color if the item is also not an image file.

 

How can I achieve this?

 

formula to check if any of the attachments in the attachment control are not of image type: 

CountRows(Filter(ctrlAttachments.Attachments.Name,Right(Name,3) <> "png",Right(Name,3) <> "jpg",Right(Name,3) <> "jpeg",Right(Name,3) <> "gif"))
 
I'm not sure how to properly reference each attachment to be able to check the name of the attachment so I can change the color...
If(Right(ThisItem.Attachments.Name,3) !In ["jpeg","jpg","png","gif"],Color.Red,Color.Blue)
Categories:
  • WarrenBelz Profile Picture
    156,956 Most Valuable Professional on at

    Hi @iwonder ,

    This is probably better as you have a 4 letter extension in there.

    If(
     !(
     Last(
     Split(
     ThisItem.Attachments.Name,
     "."
     )
     ).Value in ["jpeg","jpg","png","gif"]
     ),
     Color.Red,
     Color.Blue
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • iwonder Profile Picture
    1,146 on at

    Hi @WarrenBelz 

     

    Thank you for your reply.

    I found another thread you replied to regarding removing the last attachment (unsaved) in the control if the file extension was not of a certain type and you said it always looks at the second last one... I think that's a bug in the attachment control.

     

    I see the same thing when I try to change the color of the attachments using ItemFill. If I have 2 saved already and then add a new one (unsaved), the unsaved attachment does not pick up color from ItemFill or AddedItemFill.

     

    ThisItem.Attachments.Name is an invalid reference... so I've been trying ThisItem.Name. When I use this, the formula is valid, however it's never true...

     

    If(Right(ThisItem.Name,3) in colValidImageExt,Color.Blue,Color.Red)

     

    Again, if I have 2 attachments already saved for the record and add a new one (unsaved) the first 2 are Red and the unsaved is white even if I put the same formula in AddedItemFill.

     

    interesting note: If I put a Notify(ThisItem.Name) on the OnAddFile, the message is my email address....NOT the name of the attachment... very strange... BUT if I do this, I do get the correct response:

    If(Not(Right(ThisItem.Name,3) in colImageType),Notify(...

     

    I made a gallery with Items of the Attachment control. I was able to use the same formula and return true or false for each record, even the unsaved one! So the formula works, it just doesn't work in the Attachment Control.

     

    I also tried 'File Name With Extension' with no success.

     

    So for now I've abandoned this as I'm convinced the attachment control has bugs.

     

    have a great weekend!

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 243 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 190 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 135

Last 30 days Overall leaderboard