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 / Validation for attachm...
Power Apps
Answered

Validation for attachment control

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi everyone,

Newbie here. I would like to have a checkbox ticked once the file attached has a .PDF extension. How to better accomplish this one?

Thank you!

 

 

Categories:
I have the same question (0)
  • rubin_boer Profile Picture
    4,843 Super User 2024 Season 1 on at

    Hi @Anonymous 

     

    Add a gallery and assign its Items = AttachmentDatacard.Attatchments

    add a label and a checkbox to the gallery

    the label Text = ThisItem.Name

    the checkbox Default = If(Mid(ThisItem.Name,Find(".",ThisItem.Name)+1,3) = "pdf",true,false)

     Once the files are uploaded this is what you get

     

    rubin_boer_0-1612635489745.png

     

    hope it helps

    If this post helps you in a lot or a little, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.

     
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thank you @rubin_boer ! before creating what you have suggested though, followup question. Do I still need to create a gallery if my maximum attachment is only limited to 1 (file)?

  • Verified answer
    rubin_boer Profile Picture
    4,843 Super User 2024 Season 1 on at

     

     

    hi @Anonymous 

    you can do that as well. just remember you will have to get the first item like this:

    If(Mid(First(DataCardValue20.Attachments).Name, Find(".",First(DataCardValue20.Attachments).Name)+1,3) = "pdf",true,false)

     

    rubin_boer_0-1612676407026.png

    If this post helps you in a lot or a little, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.

     
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Ah, it did work. However, I want to use the existing checkbox outside the gallery. The checkbox already has an existing string for Default and would just like to add another condition: when .PDF is uploaded in the attachment, checkbox is ticked.😁

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Sorry forgot to mention @rubin_boer  that I tried adding (&&) your suggested IF condition in my existing checkbox's DEFAULT, no squiggly lines but doesn't seem to work.

  • rubin_boer Profile Picture
    4,843 Super User 2024 Season 1 on at

    hi @Anonymous 

     

    Can you please share the existing string in default.

     

    In the image below the checkbox in the control reference is in a gallery and the gallery is set to the attachments of the datacard hence the Thisitem.Name. The checkbox outside of the control have the default as "

    If(Mid(First(DataCardValue20.Attachments).Name, Find(".",First(DataCardValue20.Attachments).Name)+1,3) = "pdf",true,false)" which references the actual datacard and not "ThisItem".

    rubin_boer_0-1612698175000.png

    PS

    You can add the current string in the

    If(

      (Mid(First(DataCardValue20.Attachments).Name, Find(".",First(DataCardValue20.Attachments).Name)+1,3) = "pdf") && (Another condition here),
      true,
      false
    )

     
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @rubin_boer , Using your string alone worked, but when I add the existing string: (TextInput1.Text = "Priority"), true, false) - both strings do not work..weird.

    So I tried taking out "(" and ")" when adding the existing string, like this: 

    If(

      (Mid(First(DataCardValue20.Attachments).Name, Find(".",First(DataCardValue20.Attachments).Name)+1,3= "pdf") && TextInput1.Text = "Priority",
      true,
      false
    )

    - no squiggly lines but the string for the data card doesn't work. 

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 551

#2
WarrenBelz Profile Picture

WarrenBelz 430 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 298

Last 30 days Overall leaderboard