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 / Problem with If statem...
Power Apps
Answered

Problem with If statement based off a variable, it doesn't work unless I cut and paste it again.

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello, 

 

I want to change te bordercolor of textfields when users are trying to submit, but haven't filled in that textfield. 

 

I've used the following formula: If(IsBlank(B_Input_Adres) && Check = 1; Red; RGBA(0; 18; 107; 1))

B_Input_Adres = the name of the textfield and Check = the variable that can be 0 or 1. 

 

The weird thing is that it worked when I put the code in the first time, but when I save the app and return to it, it doesn't work anymore. Strange thing is that when I cut and paste it works again. 

 

Anyone has an idea of why this is? Thanks you in advance!

Categories:
I have the same question (0)
  • eka24 Profile Picture
    20,925 on at

    If the Only idea is ti check if B_Input_Adres is blank then what are you using the variable for?

    Is the variable Check = 1 storing the another thing? If you can show the variable formula

     

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I've added that check when people are trying to submit the form

    This is the formula that sets the check variable.


    If(!IsBlank(B_Input_BN) && !IsBlank(B_Input_Adres) & !IsBlank(B_Input_Plaats) & !IsBlank(B_Input_Postcode) & !IsBlank(B_Input_CP) & !IsBlank(B_Input_Telefoon) & !IsBlank('B_Input_E-mail') & !IsMatch(B_Keuze_Provincie.Selected.Value; "") & !IsMatch(B_Keuze_Land.Selected.Value; "");Set(Bestelling; 1) ; Set(Check; 1))

     

    When everything is filled-in he sets the variable Bestelling to 1 (so the proces can continue, and else he set's check to 1. I've done this so users don't get the red outlines the first time the are reaching the page, only when the try to submit whiteout filling all the required fields. 

  • eka24 Profile Picture
    20,925 on at

    I see single & instead of double &&

    Do these & represent And
    If(!IsBlank(B_Input_BN) && !IsBlank(B_Input_Adres) & !IsBlank(B_Input_Plaats) & !IsBlank(B_Input_Postcode) & !IsBlank(B_Input_CP) & !IsBlank(B_Input_Telefoon) & !IsBlank('B_Input_E-mail') & !IsMatch(B_Keuze_Provincie.Selected.Value; "") & !IsMatch(B_Keuze_Land.Selected.Value; "");Set(Bestelling; 1) ; Set(Check; 1))

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Yeah, before they where all &&, then I try to change them all to & en later to "And", but it all didn't work.

     

    The formula should check if <name textfield> is not empty and <nametextfield> is not empty and so on. If they are all not empty the user may proceed (So bestelling becomes 1) if not true the user should be stopped (so Check becomes 1)

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    If found something else: when I start the app he gives this message by the fields that are not working:
    "Incompatible Type. We can't evaluate your formula because the values being compared in the formula aren't the same type."

     

    There is a blue line underneath the "=" sign, but when I remove the = sign en then add it back again it works.
    If(IsBlank(B_Input_Adres) && Check = 1; Red; RGBA(0; 18; 107; 1)) 

  • Verified answer
    Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I found a solution, when I add a > before the =, it keeps working. 

    If(IsBlankOrError(B_Input_Adres) && Check >= 1; RGBA(255;0;0;1); RGBA(0; 18; 107; 1))

    I have no clue why? But maybe this is logical. The value check can only be 0 or 1 in my project though.

     

    Thanks to everyone who took the time to read and respond! 

     

     

  • MaximD Profile Picture
    7 on at

    I often have this issue too. For example, I set a variable 'Set(varVisibility, true)' in the OnStart, OnVisible or Button and use this in an item's visibility by just adding 'varVisibility'. When I select the variable, it shows it contains a true value but the item remains invisible.

     

    Whenever I remove one letter of the code and undo it, the visibility works immediately. Restarting the app causes this problem. I tried many things to solve it: using an int instead of a bool, using a long syntax 'If(varVisibility=true,true,false)', adding '>=' to the syntax.

     

    I avoided the issue by using a different source as trigger instead of a variable, but it feels stupid having to do that since this should be a simple action. Hopefully there will be a proper fix in the near future.

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 June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 326 Most Valuable Professional

#2
11manish Profile Picture

11manish 168

#3
sannavajjala87 Profile Picture

sannavajjala87 75 Super User 2026 Season 1

Last 30 days Overall leaderboard