Hi there.
I have a toggle inside a gallery, used to change a "Y/N" field in a sharepoint list.
These toggles are used to describe a dispender configuration: Production linea could have more dispenser, and each dispender could have only 1 legal origin.
Inside the "Oncheck" property of my toggle i set this code:
If(
!IsBlank(LookUp('Tracelot - Origini dosatori'; ID = ThisItem.ID && Attivo = true));
false; // Se l'elemento è già attivo, non fare nulla
Set(
varProcessing;
true
);;
Set(
varCurrentItemID;
ThisItem.ID
);;
// Disattiva tutte le altre origini per questa Linea e Dosatore
ForAll(
Filter(
'Tracelot - Origini dosatori';
Linea = Radio1.Selected.Value &&
Dosatore = Title1.Text &&
ID <> varCurrentItemID
);
Patch(
'Tracelot - Origini dosatori';
ThisRecord;
{Attivo: false}
)
);;
// Attiva l'origine corrente
Patch(
'Tracelot - Origini dosatori';
LookUp('Tracelot - Origini dosatori'; ID = varCurrentItemID);
{Attivo: true}
);;
Set(
varProcessing;
false
);;
true // Mantiene il toggle attivo
)
The code is working, the only problem is that when I start the app or I refresh the data (not in this code), the "Oncheck" property seems to be triggered and this cause some errors.
What can I do to trigger the "OnCheck" property only when I manually change the toggle status?
Thanks.