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

Button with If statement

(0) ShareShare
ReportReport
Posted on by 129

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:
I have the same question (0)
  • Verified answer
    mmbr1606 Profile Picture
    14,605 Super User 2025 Season 2 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
    129 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

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 Apps

#1
WarrenBelz Profile Picture

WarrenBelz 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard