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 OnSelect comman...
Power Apps
Answered

Button OnSelect command termination due to empty field in patch

(0) ShareShare
ReportReport
Posted on by

Hello Everybody,

 

I am patching data to various SharePoint lists and want to stop all patching of data if a certain condition is met.

 

In the case below I want to stop the patch if the fields OperatorDropDown.Selected.Operator || BoxDropDown.Selected.Box || Value(SlotNoText.Text) are blank or not selected. I am attempting to stop the patch with the If(IsBlank(.... on the second row of code. Ideally I need a solution which just stops executing the remaining code at this point, displays an error message and stays on the same screen which is RCATrackOut.

 

Set(RCACount,Sum(ForAll(Filter(RCAData, BatchID = DataCardValue16_2.Text && WaferID = DataCardValue28_2.Text),0),Value));
If(IsBlank(OperatorDropDown.Selected.Operator || BoxDropDown.Selected.Box || Value(SlotNoText.Text)),Notify("Some of the fields are empty",NotificationType.Error, Navigate(RCATrackOut)));
Patch(RCAData, LookUp(RCAData, BatchID = DataCardValue16_2.Text && WaferID = DataCardValue28_2.Text),
 { 
 TrackOutTime: Now(),
 TrackOutComments: DataCardValue29.Text,
 TrackOutOperator: OperatorDropDown.Selected.Operator,
 Box: BoxDropDown.Selected.Box,
 ProductID: DataCardValue5_1.Selected.Value,
 SlotNo: Value(SlotNoText.Text),
 ProcessCount: RCACount+1 
 }
 );
Patch(BatchTrack, LookUp(BatchTrack, 'Batch ID'=DataCardValue16_2.Text && 'Wafer ID'=DataCardValue28_2.Text),
 {
 State: {Value: "TrackIn"},
 OpCode: 20,
 Box: BoxDropDown.Selected.Box,
 'Slot No': Value(SlotNoText.Text) 
 }
 );
ResetForm(Form1_1);
Reset(OperatorDropDown);
Reset(BoxDropDown);
Reset(SlotNoText);
Navigate(BrowseScreen1)

 

 

Thank you in advance.

Categories:
I have the same question (0)
  • Verified answer
    CarlosFigueira Profile Picture
    Microsoft Employee on at

    If you move the actions that you want to happen if there are no error to the third argument of the If function, then they will be executed only if the condition is false (i.e., no errors):

    Set(RCACount,Sum(ForAll(Filter(RCAData, BatchID = DataCardValue16_2.Text && WaferID = DataCardValue28_2.Text),0),Value));
    If(
     IsBlank(OperatorDropDown.Selected.Operator || BoxDropDown.Selected.Box || Value(SlotNoText.Text)),
     // This will happen if there are errors
     Notify("Some of the fields are empty", NotificationType.Error),
    
     // All the commands below will happen if there are no errors
     Patch(
     RCAData,
     LookUp(RCAData, BatchID = DataCardValue16_2.Text && WaferID = DataCardValue28_2.Text),
     { 
     TrackOutTime: Now(),
     TrackOutComments: DataCardValue29.Text,
     TrackOutOperator: OperatorDropDown.Selected.Operator,
     Box: BoxDropDown.Selected.Box,
     ProductID: DataCardValue5_1.Selected.Value,
     SlotNo: Value(SlotNoText.Text),
     ProcessCount: RCACount+1 
     }
     );
     Patch(
     BatchTrack,
     LookUp(BatchTrack, 'Batch ID'=DataCardValue16_2.Text && 'Wafer ID'=DataCardValue28_2.Text),
     {
     State: {Value: "TrackIn"},
     OpCode: 20,
     Box: BoxDropDown.Selected.Box,
     'Slot No': Value(SlotNoText.Text) 
     }
     );
     ResetForm(Form1_1);
     Reset(OperatorDropDown);
     Reset(BoxDropDown);
     Reset(SlotNoText);
     Navigate(BrowseScreen1)
    );
    

    Hope this helps!

  • rob4681 Profile Picture
    on at

    I simplified my code to test, and it works. Thank you.... now to solve the other issues.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 762

#2
11manish Profile Picture

11manish 640

#3
Valantis Profile Picture

Valantis 548

Last 30 days Overall leaderboard