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 / Button with If statement
Power Apps
Answered

Button with If statement

(0) ShareShare
ReportReport
Posted on by 133

Hi all,

I would like to put this into one of my button but it seems like its not working as intended. The button are supposed to check if certain error message labels (ErrorMessage12, ErrorMessage14, etc.) are blank, and if they are, it updates a context variable named Draft to 0 and submits a form named Form25Bs. If any of the error message labels are not blank, it should show an error notification.

The code are as follows:

If(
 IsBlank(ErrorMessage12.Text) && 
 IsBlank(ErrorMessage14.Text) && 
 IsBlank(ErrorMessage21.Text) && 
 IsBlank(ErrorMessage23.Text) && 
 IsBlank(ErrorMessage24.Text) && 
 IsBlank(ErrorMessage26.Text) && 
 IsBlank(ErrorMessage32.Text),
 UpdateContext({Draft: 0}); SubmitForm(Form25Bs),
 Notify("Error detected! Make sure that all fields are filled in without errors!", NotificationType.Error)
)

 I had 4 issues with this formulas.

4 Issues detected. 
1. Expected operator We expect an operator such as +, or & at this point in the formula. 
2. Behavior function in a non-behavior property. You can't use this property to change values elsewhere in the app. Behavior functions change the state of the app by changing values elsewhere in the app. 'Navigate', 'Patch', updateContext, and 'Collect are common behavior functions. 'Onselect•, 'OnVisible', and other 'On properties are common behavior-based properties. 
3. Incompatible type. We can't evaluate your formula because of a type error. The data may not match the expected type. (text, number, date, table, record.) 
4. The function 'If' has some invalid arguments.

How should i fix my formula? 

Categories:
  • Verified answer
    mmbr1606 Profile Picture
    14,629 Super User 2026 Season 1 on at

    hey @Appleonwindows 

     

    can you try this:

    If(
     IsBlank(ErrorMessage12.Text) && 
     IsBlank(ErrorMessage14.Text) && 
     IsBlank(ErrorMessage21.Text) && 
     IsBlank(ErrorMessage23.Text) && 
     IsBlank(ErrorMessage24.Text) && 
     IsBlank(ErrorMessage26.Text) && 
     IsBlank(ErrorMessage32.Text),
     UpdateContext({Draft: 0}),
     Notify("Error detected! Make sure that all fields are filled in without errors!", NotificationType.Error)
    );
    If(
     IsBlank(ErrorMessage12.Text) && 
     IsBlank(ErrorMessage14.Text) && 
     IsBlank(ErrorMessage21.Text) && 
     IsBlank(ErrorMessage23.Text) && 
     IsBlank(ErrorMessage24.Text) && 
     IsBlank(ErrorMessage26.Text) && 
     IsBlank(ErrorMessage32.Text),
     SubmitForm(Form25Bs)
    )
    

     

    Let me know if my answer helped solving your issue.

    If it did please accept as solution and give it a thumbs up so we can help others in the community.



    Greetings

  • Appleonwindows Profile Picture
    133 on at

    Yep it works! Thanks!

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

#2
Mohsin Ali Profile Picture

Mohsin Ali 368

#3
WarrenBelz Profile Picture

WarrenBelz 244 Most Valuable Professional

Last 30 days Overall leaderboard