Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Validating method

(1) ShareShare
ReportReport
Posted on by 42
Hello all,
 
I have a page where a user can either fill in a few text boxes or upload a document.  Either will add to a collection.  Since some of the text boxes may be empty, I'm dealing with them as shown below.  Is there an easier way to do this?  The below works, but I wanted to validate in case there was a one-liner or alternate method to achieve the same thing.
 
Collect(colUserList, [{Name: txtUserName1.Text,Email: txtEmail1.Text},{Name: txtUserName2.Text,Email: txtEmail2.Text}, {Name: txtUserName3.Text,Email: txtEmail3.Text}]);
RemoveIf(colUserList, Or(IsBlank(Name), IsBlank(Email)));
Categories:
  • Verified answer
    Michael E. Gernaey Profile Picture
    40,375 Super User 2025 Season 1 on at
    Validating method
    Hi,
     
    Do you just have like 6 text inputs on the screen??
     
    Here is another possibility.
     
    If you had a Gallery, in the gallery you added your 3 Text Inputs.
    Then you could make it show 3 rows (with no way to add or remove)
     
    Then you could do
    Now this for sure more lines, but accurately puts only the data you want in it, but how you have it, I have seen many people do. Its not wrong and you could of course, do the If clause in the Collect and make it one big line, it just gets ugly :-)
     
    ForAll(Gallery.AllItems,
        If(!IsBlank(ThisRecord.NameField.Text) And !IsBlank(ThisRecord.NextField.Text And !IsBlank(ThisRecord.NextField.Text),
        Collect(MyCollection,
          { 
             Name: ThisRecord.NameField.Text,
             Other: Thisrecord.OtherField.Text,
             OtherOther: ThisRecord.OtherOtherField.Text
          { 
        )
    );
    
    Technically you don't need to quality the ThisRecord in the Collect.
    
     
     

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,524 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,906 Most Valuable Professional

Leaderboard