How to move with ListMove, up and down, but without overwriting the others?

I want to move users from a list, but it is overwriting when I move a user up or down. For example: I have registration and name in the list and I'm trying to move a user up or down, but when I do that, it overwrites the other user on that list. I tried to adapt Forge's ListMove and until then everything was OK. But that part is the missing part to complete my priority queue.

I appreciate the help!

Matheus Lorran.

What's exactly the name from Forge's element you are using?

Maria da Graça Peixoto escreveu:

Qual é exatamente o nome do elemento do Forge que você está usando?


Rich Widget Sample

In the action you are using on the "on Notify" property you are inserting a row in the list position

 (system action  'ListInsert' - Inserts an element in a specific position of a list. ) 

or overwriting the existing row ? 

In the sample they have a position field in the data base and that's what is being used order the rows, If you have used that logic, review the indexes you are using 

SyntaxEditor Code Snippet

Customer_CustomerAddressTable.List[Customer_CustomerAddressTable.List.CurrentRowNumber].CustomerAddress.PreferredOrder - 1

Matheus Lorran wrote:

I want to move users from a list, but it is overwriting when I move a user up or down. For example: I have registration and name in the list and I'm trying to move a user up or down, but when I do that, it overwrites the other user on that list. I tried to adapt Forge's ListMove and until then everything was OK. But that part is the missing part to complete my priority queue.

I appreciate the help!

Matheus Lorran.

Hello Matheus,

'List_Move' is a widget with the purpose of moving rows up and down, with arrows. This widget can be used on TableRecords and ListRecords.

When using this widget, we should have an attribute like 'Order' if we want to keep in DB the changes made on screen.

In 'On notify' logic from this widget we want to catch the notification. For this purpose we can use 'Deprecated_NotifyGetMessage' to catch the message after we click an arrow from 'List_Move' Widget.


This action will output 'UP' or 'DOWN' depending on what arrow we clicked. 

After this we can just put an IF and set the 'Order' attribute from the object.

We can't forget to change all the rows affected after this. 


Hope I could be helpful. 


Best Regards,

Tomás Dionísio.


Maria da Graça Peixoto  escreveu:

Na ação que você está usando na propriedade "ao notificar", você está inserindo uma linha na posição da lista

 (ação do sistema 'ListInsert' - Insira um elemento na posição específica de uma lista.) 

ou substituindo a linha existente? 

Na amostra, eles têm um campo de posição na base de dados e isso é usado para ordenar como linhas. Se você usar essa lógica, revisar os índices que está usando 

Snippet de código do editor de sintaxe

Customer_CustomerAddressTable.List [   Customer_CustomerAddressTable.List.CurrentRowNumbe   r   ] .CustomerAddress.PreferredOrder - 1







Obrigado por trazer esta solução. Vou tentar esta solução e em breve trarei mais informações sobre o progresso.












Cumprimentos, 

  Matheus Lorran.










Tomás Dionísio wrote:

Matheus Lorran wrote:

I want to move users from a list, but it is overwriting when I move a user up or down. For example: I have registration and name in the list and I'm trying to move a user up or down, but when I do that, it overwrites the other user on that list. I tried to adapt Forge's ListMove and until then everything was OK. But that part is the missing part to complete my priority queue.

I appreciate the help!

Matheus Lorran.

Hello Matheus,

'List_Move' is a widget with the purpose of moving rows up and down, with arrows. This widget can be used on TableRecords and ListRecords.

When using this widget, we should have an attribute like 'Order' if we want to keep in DB the changes made on screen.

In 'On notify' logic from this widget we want to catch the notification. For this purpose we can use 'Deprecated_NotifyGetMessage' to catch the message after we click an arrow from 'List_Move' Widget.


This action will output 'UP' or 'DOWN' depending on what arrow we clicked. 

After this we can just put an IF and set the 'Order' attribute from the object.

We can't forget to change all the rows affected after this. 


Hope I could be helpful. 


Best Regards,

Tomás Dionísio.


Thanks for the reply. I already assigned this role, it already exists in my action. The problem is that it is overwriting the user on the list. Move until move, but overwrite.
My regards,
Matheus Lorran.


Hello Matheus,


The problem might be on assign. You are probably assigning one to another.
If you are trying to move Element2 to Element1, you must firstly hold the Element1 on a local variable (example: Element_tmp = Element1) then assign Element1 = Element2, and then Element2 = Element_tmp.

In this case you never loose any elements of the list, and you don't overwrite it.


Best Regards,

Tomás Dionísio.  


Please, when answering the questions, don't copy the previous answers all, as it will make the forum very extensive and more difficult to help. If you need to refer to a point mentioned earlier, just do that point. Thanks.

Tomás Dionísio escreveu:

Olá Matheus,


O problema pode estar na participação. Você provavelmente está atribuindo um outro.
Se você estiver tentando mover o Elemento2 para o Elemento1, primeiro mantenha o Elemento1 em uma variável local (exemplo: Element_tmp = Elemento1), depois atribua Elemento1 = Elemento2 e, em seguida, Elemento2 = Elemento_tmp.

Nesse caso, você nunca perde nenhum elemento da lista e não substitui.


Cumprimentos,

Tomás Dionísio.  


Por favor. Observe atentamente cada imagem, pois elas são diferentes. É assim na minha parte do OnNotify. Foi isso que consegui adaptar ao meu sistema. Alguém sabe apenas olhando por que eles estão substituindo o outro usuário na lista quando tento mover cada um?


SyntaxEditor Code Snippet

List_Navigation_GetStartIndex(Customer_CustomerAddressTable.Id, True)  
Before I used this, now I left it with the image above and the same.

Hi Matheus,

Can you reproduce the problem in a simple module and share here. I will look into it.

Regards,

Marcelo

Hi again Matheus!

In your eSpace you are using the entity Identification (Fila.Id) to order the records in the table. Well , the Id from a record is the way we say to the data base which record we want to work with, so when you get a record contents , change the Id field and call the Update Action with the new content, what you are doing is changing the record with that Id.

Say , you have the record like : 

   Id = 1

   Name =Ana 

   Address = Moon

 And you change it to

   Id =3

   Name =Ana 

   Address = Moon

and call the update with it what you are doing is change the record with the id = 3 to have : 

  Name =Ana 

  Address = Moon


To be able to change the order it is better to have a field only to handle the position like André Mota did in the sample. 

Hope this helps you 

Regards

Graça

Maria da Graça Peixoto wrote:

Hi again Matheus!

In your eSpace you are using the entity Identification (Fila.Id) to order the records in the table. Well , the Id from a record is the way we say to the data base which record we want to work with, so when you get a record contents , change the Id field and call the Update Action with the new content, what you are doing is changing the record with that Id.

Say , you have the record like : 

   Id = 1

   Name =Ana 

   Address = Moon

 And you change it to

   Id =3

   Name =Ana 

   Address = Moon

and call the update with it what you are doing is change the record with the id = 3 to have : 

  Name =Ana 

  Address = Moon


To be able to change the order it is better to have a field only to handle the position like André Mota did in the sample. 

Hope this helps you 

Regards

Graça


Maria!
Many thanks for the reply. What you really said was this problem, however, I changed and used another table and did exactly as André Mota did. However, when you move, receive this error:

[OSDEV1] .DBO. [OSUSR_KO6_FILAMOVE] with key 0 has not been updated 


I saw that it has to do with null key, but I didn't understand it well. Because I did very close to what André did, I probably haven't realized my mistake yet, but do you know how to resume it?







I do not have a clue. 

Try to "debug" you code, to understand what is the point where the Id is null


Hey Maria, look at this! 

Look what is causing the error mentioned earlier.
greetings, 

Matheus Lorran.

It seams you are trying to move "up" the first line Matheus!?

If the parameters are properly filled it should not happens, but you need make some experiences to fully understand the way this widget works. Try to add a column to your table and display there the parameters you are using in the List_Move widget, the Fila record Id and any other values you think you need to process "by hand" your action. Some times following the action flow ourselves is the only way to find the problem. 

Regards

Graça


 



Hey!

These are my databases that I use in my queue system. I wanted to understand how exactly this problem occurred. I understood your solution Maria. But in André Mota's example, he used only two tables to make the Movement on the list. Now I'm trying to make a mirror of what he did, with these 2 tables: Fila and FilaMove.








Note!
I am very attentive in this part of the preparations. Perhaps here may be part of the problem. This parameter issue can probably be the CurrentRowNumber issue for my system to be different: -1 and +1 to make it go up and down. But this error of updating I don't even know how to find it.


Note!

Here too, I may have to adapt better as it is forging what André did.

Maria da Graça Peixoto wrote:

It seams you are trying to move "up" the first line Matheus!?

If the parameters are properly filled it should not happens, but you need make some experiences to fully understand the way this widget works. Try to add a column to your table and display there the parameters you are using in the List_Move widget, the Fila record Id and any other values you think you need to process "by hand" your action. Some times following the action flow ourselves is the only way to find the problem. 

Regards

Graça


 Hey Maria! 

Looks like my definitions posted here on the topic. To see if you might have a better view than I did. As I said I tried to adapt or closer to André. I don't know if you did exactly like him, because maybe some of those things that are at the root may be at the root of the problem.