ForAll(
Filter(
Gallery1.AllItems, Checkbox2_1.Value = true //for all, filter gallery1 for checked boxes
) As _Data, //call this data '_data'
With(
{
_Records:
Filter(
ECI_Dies_1,
dienum = Gallery1.Selected.Checkbox2_1.Text &&
eci_id = SelectedRecordTitle1_1.Text
) //Filter ECI_Dies_1 table for records where dienumber and ECI ID matches Record selections in the form
},
If(CountRows(_Records) <1, //If true, then Patch otherwise do nothing
Patch(
ECI_Dies_1,
{
dienum: _Data.Checkbox2_1.Text,
eci_id: SelectedRecordTitle1_1.Text,
product: DataCardValue9.Selected.Value,
content: DataCardValue4_1.Text,
eci_level: DataCardValue3_1.Text,
trial: Checkbox8.Value,
cavity: DataCardValue2.Selected.Value,
Priority:DataCardValue11.Selected.Value,
Purpose:DataCardValue6.Selected.Value,
request_date:DateValue1.SelectedDate
} //Data list patching to Eci_dies_1 SP list
)
)
)
);
UpdateContext(
{
CurrentItem: Self.LastSubmit,
editMode: false,
newMode: false
} //submit form data to Table_ecis SP list
)
This code is supposed to identify which checkbox2_1's are checked then for each of those checked, then
of those being checked does ECI ID and Checkbox2_1 values occur in ECI_Dies_1 SP list, If they DO then do not patch if they DO NOT
Then patch, then update\append other form data to Table_ECIs list (not listed because this is the main datasource of the screen)
Where i have a problem is the portion of the code ABOVE the patch. I can not get it to stop creating duplicate child records.
I have a perfect case in my data that I am testing - the record selected had 6 and 7 unchecked therefore in the original submission ECI_Dies 1
has only 1 2 3 4 and 5 child records. if i click the pencil, check the 6 and 7, then click submit. it should only add child records or 6 and 7
but instead it is adding not only for 6 and 7 but another set for 1 through 5
Putting cursor in my patch just after the first filter code correctly shows i have check boxes for dies 1 through 5 checked. i think where its not working is
after 2nd filter putting my cursor says theres no data. so I believe this is why it continues to patch for all the check boxes