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.
I simplified my code to test, and it works. Thank you.... now to solve the other issues.
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!
WarrenBelz
146,645
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,997
Most Valuable Professional