Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building 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.

  • rob4681 Profile Picture
    on at
    Re: Button OnSelect command termination due to empty field in patch

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

  • Verified answer
    CarlosFigueira Profile Picture
    on at
    Re: Button OnSelect command termination due to empty field in patch

    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!

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,645 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,997 Most Valuable Professional

Leaderboard