I have a App where Models have Operations and so on...
What I'm trying to do is to send a Model's Operations to a collection, along with a new column called "order".
The main objective of the column is so that when the collection is put on a gallery, it will have 2 buttons, Up and Down, where it re-orders the position of the item using the order column.
To do that, I used the sequence function to create a sequence of numbers from 1 to the Count of Rows that the collection has, so if the collection has 4 rows, the order column will be 1 - 2 - 3 - 4 .
The problem is that the Order column is not working properly, as seen in the picture below:
The Sequence function itself is working, but the way it is placed on the collection is why I am here.
As you can see the Order column has 1 - 2 - 3, because the Model that it came from had 3 Operations, hence the 1 - 2 - 3.
So that's the problem, I need to find the correct syntax that doesn't cause that error.
Here is my code:
ClearCollect(colModOp;Filter('Modelos&Operações';ThisItem.ID = RefIDModelo);{Ordem:Sequence(CountIf('Modelos&Operações';ThisItem.IDModelo = RefIDModelo))});;
Any help would be awesome 😁
Solved! Go to Solution.
With(
{records: Filter('Modelos&Operações';ThisItem.ID = RefIDModelo)},//your filter and sort
ClearCollect(
colModOp;
ForAll(
Sequence(CountRows(records));
Patch(
Index(
records,
Value
),
{rowNumber: Value}
)
)
)
)
With(
{records: Filter('Modelos&Operações';ThisItem.ID = RefIDModelo)},//your filter and sort
ClearCollect(
colModOp;
ForAll(
Sequence(CountRows(records));
Patch(
Index(
records,
Value
),
{rowNumber: Value}
)
)
)
)
IT WORKS, THANK YOU SO MUCH!!!
Now it's just patching between the row numbers and my Re-Order buttons can work!
Hey, @Drrickryp !
I have a question. I am using your formula to create a Re-Order button (Up and Down) to manually sort the Items of a gallery. But if I just stay by the normal Patch + 1 and Patch - 1, there will be cloned Order numbers.
I tried to make this way:
Patch(colModOp;ThisItem;{Ordem:ThisItem.Ordem + 1});;
Patch(colModOp;LookUp(colModOp; ThisRecord.Ordem = ThisItem.Ordem + 1;ThisRecord);{Ordem: ThisItem.Ordem - 1})
(This is for the down arrow, swapping the operators gives you the up arrow.)
What I mean by that code is that the Item you are currently on has a Order of 1, and the next one is 2. Supposedly, the could should've make the 1 be 2 and the 2 be 1. But It seems to make things worse.
Any tips to make this more bugless?