Hi all,
I have built an app with the following logic:
- Creates a collection A with data.
- Creates a collection Loop used to loop through collection items.
- Uses a ForAll() to loop for a specific number of times using Loop, and filters accordingly
- For each iteration in the loop, a behavior custom function Function1 is called which performs the following:
- Clears a temporary collection Temp
- Uses a ForAll() function to filter collection A using the row id (using the Loop collection's data) and creates a JSON object to convert the row data to column, storing the column data in Temp.
- A new collection is created using Collect() called Temp2 which is used to format the data in a particular order and to include specific data (rather than all the data extracted using the JSON() function.
- For each iteration in the loop, another behavior custom function is called which creates a new collection from Temp2.
The loop collection is created as follows:
ClearCollect(
Loop,
{Index: 1},
{Index: 2},
{Index: 3},
{Index: 4},
{Index: 5}
);
The following is the code used in Function1:
Clear(Temp);
ForAll(Filter(A,id=rowId),//gets row from costmodel collection
ForAll(Split(Substitute(Substitute(JSON(ThisRecord,JSONFormat.IgnoreBinaryData),"{",""),"}",""),","),//uses JSON object to convert it to a column
Collect(Temp,Split(Result,":").Result)));//stores the result in a collection
Collect(Temp2,
{
//adding row data, using data passed as parameters and data from the column created from the row
});
The following is the code used in Function2:
ClearCollect(B, Temp2);
This does work when I click the button, which is the component. However, if I click the button again, the values generated are not as expected (incorrect). If I wait 40 seconds before pressing the button, it works as expected. If I click it sooner, it does not work as expected.
Has anyone ever experienced this? Any suggestions on how I can fix it?
Thanks in advance!