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

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
    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

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 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard