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 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,368 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,368 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

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 Pages

#1
Jerry-IN Profile Picture

Jerry-IN 71

#2
Fubar Profile Picture

Fubar 62 Super User 2025 Season 2

#3
sannavajjala87 Profile Picture

sannavajjala87 31

Last 30 days Overall leaderboard