Hello,
I have a formula which worked great but started having issues when the datatable started growing. Data is stored in Dataverse.
So what the formula does is it checks if it has patched something already and ignores the patch if it has. It patches a certain number of new items to dataverse. This number is defined in a gallery row. ForAll then completes this formula for the specified amount of times.
Before issues I had Last(RIVITIEDOT).ID instead of First(Sort(RIVITIEDOT; Luotu; SortOrder.Descending)).ID in my formula. But the Last function stopped showing the true last record of the table.
The issue Im having now is in ForAll function where First(Sort(RIVITIEDOT; Luotu; SortOrder.Descending)).ID doesn't fetch the last record in time and it results in patching same ID multiple times. Is there a way to make ForAll function wait before it continues the sequence? Or is there a better way to do this?
Formula below:
Select(Parent);;
If(LookUp(RIVITIEDOT; Työnumero = ThisItem.ID; Työnumero) <> ThisItem.ID;
Patch(RIVITIEDOT; {ID: First(Sort(RIVITIEDOT; Luotu; SortOrder.Descending)).ID + 1; Työnumero: ThisItem.ID; Rivinumero: First(Sort(RIVITIEDOT; Luotu; SortOrder.Descending)).ID + 1});;
ForAll(Sequence(ThisItem.Määrä - 1); (If(Value(ThisItem.Määrä) > 1; Patch(RIVITIEDOT; {ID: First(Sort(RIVITIEDOT; Luotu; SortOrder.Descending)).ID + 1; Työnumero: ThisItem.ID; Rivinumero: First(Sort(RIVITIEDOT; Luotu; SortOrder.Descending)).ID + 1})))));;
Navigate(Screen_Rivitiedot; ScreenTransition.Cover)
BR,
Tomi