Hi all,
I have a canevas app, where a collection is modified by controls in a screen. The items of the collection come from a Dataverse table.
It is named Etudes_Co and has a column to store if :
- the record has been newly created (not in the table yet),
- the record has modified (table is to update)
- the record is unchanged from the table
I would like to update the dataverse table which is named tbEtudes with values from the collection.
I don't have any problem to patch the records which are newly created.
The issue is when i try to update records which already exist. Then the modifications are applied to the last created record in the table, wether modified or not.
Does someone have an idea of where i have a fail in the code ?
ForAll(Etudes_Co;
If(ThisRecord.modif="modif";
Notify("traitement " & ThisRecord.codeAffaire);;
Patch(tbEtudes;LookUp(tbEtudes;tbEtudes[@ythabo_codeaffaire]=ThisRecord[@ythabo_codeaffaire]);
{
ythabo_nom:ThisRecord[@ythabo_nom];
ythabo_client:ThisRecord[@client];
ythabo_statut:ThisRecord[@statut];
ythabo_budgetglobal:ThisRecord[@budgetGlobal];
}
));;
If(ThisRecord.modif="créa";
Notify("Enreg" & ThisRecord.codeAffaire);;
Patch(tbEtudes;Defaults(tbEtudes);
{ ythabo_codeaffaire:ThisRecord[@ythabo_codeaffaire];
ythabo_nom:ThisRecord[@ythabo_nom];
ythabo_client:ThisRecord[@ythabo_client];
ythabo_statut:ThisRecord[@ythabo_statut];
ythabo_budgetglobal:ThisRecord[@ythabo_budgetglobal];
}
));;
ThisRecord.modif="non"
);;