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 / IF(LEN()) not working ...
Power Apps
Unanswered

IF(LEN()) not working as expected

(0) ShareShare
ReportReport
Posted on by

Hi All,

I am trying to customize a form from an SPO list, since Microsoft in their infinite wisdom can't format a phone number on a form, I am trying to  force the user to enter 10 digits into the form.  This should be easy enough, but for some reason it's not.

 

  1. On visible of the form I Set(Var10Digits,false)
  2. I set "OnChange to :If(Len('Phone Number')<>10,UpdateContext({Var10Digits: true }));
  3. I have a textbox and button visible when var is true
  4. I set the var back to false when button is pushed

Simple enough solution?

I get the textbox and button no matter what I put in the column.  Why would the Var be set to true even when there are 10 digits? 

I tried every way I can think of. 

Am I doing this in the wrong place?  

 

Any help would be greatly appreciated!

TIA,

Joe

Categories:
  • mdevaney Profile Picture
    29,993 Moderator on at

    ...deleted post...

  • joef Profile Picture
    on at

    @mdevaney ,

    Did you try to post something? 🙂

    Your response is blank 

     

  • mdevaney Profile Picture
    29,993 Moderator on at

    @joef 

    My recommendation here would be not to rely on a context variable.  Instead I would build a validation inside the textbox and buttons to check the length.

     

    Put this code in the Visible property of both your text box and button

    Len(PhoneNumber.Text)=10

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • joef Profile Picture
    on at

    hi @mdevaney ,

    Thanks for the response...

    Good thought, but when the form opens so does my error message saying to enter 10 digits. 

    Phone is not required (and the business doesn't want it to) so I can't have the box there until they mess up the entry of 10 digits..

    That's the reason for checking Len() on change.

     

    Thanks again,

    Joe

  • mdevaney Profile Picture
    29,993 Moderator on at

    @joef 

    Good to know lol.  Can’t blame a guy for taking the simplest path forward when solving a problem 😉

     

    The reason for your issue is you have used both SET and UPDATECONTEXT for the same variable.  This is not allowed in PowerApps; you must use one or the other.  See my example below.


    Set(Var10Digits,false);

     

    :If(Len('Phone Number' <>10, Set({Var10Digits: true }))

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

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 382 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 329

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard