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 Pages / Validation that a file...
Power Pages
Unanswered

Validation that a file column has a file upload only when one or more yes/no fields = yes

(0) ShareShare
ReportReport
Posted on by 5

full disclosure, I am a newbie, I don't know what I don't know. 

I'm using validators reasonably successfully in this page and others, but I cannot figure this one out.

There are 5 yes/no fields on my page and a hidden file column field.
if any of fields 1-4 is "yes", the file field is revealed. 

I would to add a validator that checks that there is a file entered in the field, but only if any of fields 1-4 is yes.

I have everything up to the evaluation function, and the "check fields" portion of the evaluation function is straightforward (the same as the working hide/show logic - ugly but functional 😉) but I cannot fathom how to check that there is a file uploaded. 

If anyone could help me with that logical test, I would be truly grateful! 

I've cannibalised the built-in evaluation function used when making the file column required in studio  ValidatorTrim(ValidatorGetValue(val.controltovalidate)) != ValidatorTrim(val.initialvalue)
but no joy. There doesn't seem to be much out there in google or chatGPT that understands file column - all the suggestions have been to check the length of the first element of files and my understanding is that a file column is a single binary object?

What method or technique do I use to check that the file column is not empty???
TYVM in advance!

Categories:
I have the same question (0)
  • oliver.rodrigues Profile Picture
    9,482 Most Valuable Professional on at

    Hi

     

    my implementation here would be something like:

     

    • Add on.change event handlers to Yes/No fields (it seems you have that working fine)
    • Add validation to the page with the Evaluation Function being something like:
      • if (choice1 == YES || choice2 == YES || choice3 == YES || choice4 == YES)
        • check if file contains data
  • PatJazzy Profile Picture
    5 on at

    Thank you. I was thinking along those lines, but it was specifically "check if file has data" that I was having trouble with. I couldn't figure out how to establish if a file column has data in it.

    In the end, I used this as part of the logical test that worked - or rather, didn't fail!
     document.querySelector("#my_field_file_name").textContent.length == 0

     

    I can't testify to the elegance of the statement but it got me out of a hole 😁

  • oliver.rodrigues Profile Picture
    9,482 Most Valuable Professional on at

    You can use 

    $("#<your file column>_input_file").val();

    if that is empty it's missing the file 

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
Mohsin Ali Profile Picture

Mohsin Ali 33

#2
sannavajjala87 Profile Picture

sannavajjala87 28 Super User 2026 Season 2

#3
Fubar Profile Picture

Fubar 22 Super User 2026 Season 1

Last 30 days Overall leaderboard