Hi
I have a collection that is triggered when something is changed in a gallery controls
Then i have a button where i add new lines and upon adding a line i check if there is something in collection and if yes i patch the recor5ds with the value in collection and then i clear that collection and create new record but with that when io create new record all existing records in that gallery are added to collection again. I can't figure out what cause it to act like that. please help me figure it out, This is my code:
//---Check if something exists in collection
If(
CountRows(colTaskUpdatesDarbai)>0,
Patch(
Remontai,
ForAll(
colTaskUpdatesDarbai,
Patch(
LookUp(Remontai,new_RemontaiId=ThisRecord.Remontai),
{
//---Update records in Table with collection values
//new_irasotipas:"0",
// new_uzsakymonumeris: LookUp(Uzsakymai,'Užsakymo numeris'=ComboBoxUzsakymoNumeris.Selected.Result),
new_uzsakymonumeris: LookUp(Uzsakymai,'Užsakymo numeris'=ComboBoxUzsakymoNumeris.Selected.'Užsakymo numeris'),
//new_data: new_data,
//new_valstybinisnumeris:LookUp(Automobiliai,'Valstybinis numeris'=new_valstybinisnumeris),
//new_automobiliorida:Value(new_automobiliorida),
new_darbukategorija: LookUp('Darbų kategorijos',new_darbukategorija=cnew_darbukategorija),
new_darbas: LookUp(Darbais,'Darbo pavadinimas'=new_darbas),
new_darbuotojas:LookUp(Darbuotojai,'Darbuotojo kodas'=cnew_darbuotojas),
new_kiekis: Value(new_kiekis),
new_kaina:Value(new_kaina),
new_suma:Value(new_suma)
}
)
)
);
Clear(colTaskUpdatesDarbai);
//----After update create new record
Patch(
Remontai,
Defaults(Remontai),
{
new_uzsakymonumeris:LookUp(Uzsakymai,'Užsakymo numeris'=ComboBoxUzsakymoNumeris.Selected.'Užsakymo numeris')
//new_valstybinisnumeris:LookUp(Automobiliai,'Valstybinis numeris'=ComboBoxValstybinisNumeris.Selected.'Valstybinis numeris')
}
),
Clear(colTaskUpdatesDarbai);
//----If nothing exists in collection create new record
Patch(
Remontai,
Defaults(Remontai),
{
new_uzsakymonumeris:LookUp(Uzsakymai,'Užsakymo numeris'=ComboBoxUzsakymoNumeris.Selected.'Užsakymo numeris')
//new_valstybinisnumeris:LookUp(Automobiliai,'Valstybinis numeris'=ComboBoxValstybinisNumeris.Selected.'Valstybinis numeris')
}
)
);
Clear(colTaskUpdatesDarbai);
Even after last Clear the collection still exists