41
Views
9
Comments
Solved
Check for changes from one list to another list.
Question

Hello!
I am trying to check changes from one lists to another list and having a difficult time. Anyone can share ideas how to implement it? I have this 2 lists to check for changes.
One list is the "SelectedChecklist" and the other is the "GetSelectedChecklist". I need to check changes from GetSelectedChecklist to SelectedChecklist. Please see image for reference.

2020-11-25 10-45-32
Mostafa Othman
Champion
Solution

Hello,

I assume that GetSelectedChecklist is the original one and SelectedChecklist is the one that updated by the user, if that correct:

- You will need to loop SelectedChecklist using for each and use ListAny function (by checking with a unique identifier)  to check if this item exists into GetSelectedChecklist.

- If you found the item into GetSelectedChecklist but your business requirement to check if item itself edited or not so you have to compare each attribute of that item

- If item not exist so its newly added item

- If you want to check any deleted items so you need to loop GetSelectedChecklist and check items that not exist into SelectedChecklist using ListAny also

2024-12-18 16-06-42
Junaid Syed

Hello,

When you say you want to check the changes between two list, does it mean you want to know that how many records are selected from original list or you want to identify the items which have the value changed for one or more attributes?

If you just want to check the selected items, you could simply use the list filter applying it on some common attribute for instance the identifier of the list records.

Whereas if you want to check on the value changes for attributes, please check the forge component to see if it meet your needs.

https://www.outsystems.com/forge/component-overview/14299/list-utilities-o11

Other option is to loop through the items in the two list and compare the attributes for changes.

Here is a similar post

https://www.outsystems.com/forums/discussion/75473/comparing-list-in-outsystem-reactive-web/

Hope it helps!

Junaid

2020-11-25 10-45-32
Mostafa Othman
Champion
Solution

Hello,

I assume that GetSelectedChecklist is the original one and SelectedChecklist is the one that updated by the user, if that correct:

- You will need to loop SelectedChecklist using for each and use ListAny function (by checking with a unique identifier)  to check if this item exists into GetSelectedChecklist.

- If you found the item into GetSelectedChecklist but your business requirement to check if item itself edited or not so you have to compare each attribute of that item

- If item not exist so its newly added item

- If you want to check any deleted items so you need to loop GetSelectedChecklist and check items that not exist into SelectedChecklist using ListAny also

UserImage.jpg
RD.

 The goal is to identify the items which have the value changed for one or more attributes.

2020-11-25 10-45-32
Mostafa Othman
Champion

I may suggest to convert your lists to Json and compare them using this forge component:

https://www.outsystems.com/forge/component-overview/16736/json-compare-o11 

2024-12-02 13-16-47
Vipin Yadav

Hi RD,

You need to add below logic for resolve this issue  -

  1. In SelectedChecklist  to store the result of the comparison on. For this you will want to create a chart that matches your search criteria but adds an additional Boolean attribute to specify variables.
  2. Loop through a list (for example, GetSelectedChecklist) using the List Operation or the For Each node.
  3. Check if each item in the loop is in another list (SelectedChecklist) and if its properties match. You can do this by using the ListFilter function to filter the SelectedChecklist based on the identity of the current item from the GetSelectedChecklist.
  4. Compare material quality. If there is a difference, set the Boolean attribute of the variable in that object to True, and add the object to your Local Variable that stores the variable.
  5. After the loop, you will have variables that you can use to update the SelectedChecklist, present it to the user, or perform other actions as needed.

if possible please share .oml file so that i will do the changes.

Thanks,

Vipin Yadav

UserImage.jpg
Rounak Rawat

Hii @RD. 

To assist you further, I’ve attached a file that contains the relevant details or implementation steps.

Feel free to review it and let me know if you have any further questions or need clarification. I’d be happy to help.

Best regards,

Rounak Rawat

Move items_test.oml
UserImage.jpg
Rounak Rawat

Hii @RD. 

I have attached one more file if you don't want to changes on server side.

Hope it helps you,

regards 

Rounak Rawat

Move items_test2.oml
2024-07-12 05-57-50
Gourav Shrivastava
Champion

Hello @RD. 

You can follow (Steps to Implement):

  1. Define Temporary Lists:

    • Create three temporary lists to hold added, removed, and updated items.
  2. Iterate Through Lists:

    • Loop through GetSelectedChecklist and check:
      • If an item doesn’t exist in the SelectedChecklist, add it to the "Removed Items" list.
      • If it exists but has changes, add it to the "Updated Items" list.
    • Then loop through SelectedChecklist to find items not in GetSelectedChecklist and add them to the "Added Items" list.
  3. Use Conditions for Comparison:

    • Use the ListFilter function or a combination of For Each Loop and If conditions to compare each item’s properties.


eg: OutSystems also follows the same steps while we implement offline sync on mobile devices. 

Thanks 

Regards,

Gourav Shrivastava

UserImage.jpg
RD.

Appreciate all your response everyone. Thank you.

For this, I use the Loop and ListAny function. Checking each current SelectedChecklist one by one if there are changes and then updating it, if has changes.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.