Comparing 2 lists and adding element when false
Question

Hello,

Im working on a project where i have 2 lists. Both of them are displayed in the UI as tables. Goal is to add an element to certain object in a list when user edits the data through a dropdown. How can i compare the original list and the edited list to see if the certain object inside the list has been edited?

Unfortunately i cannot share the .oml file or any other detailed information related to the app.

Cheers alrdy

Hello @Ronivil 

Can you please elaborate the exact requirement ?


Regards,

Pramod.

mvp_badge
MVP

Hi Ronivil,

I don't quite understand your question, especially the "goal is to add an element to [a] certain object in a list", since it doesn't seem to align with the remainder of the question ("how can I compare the original list and the edited list").

Could you please explain better what the lists are, what happens on editing, and what you want to be able to check?

Hello,

Flow is the following: 

  • There is a table with rows of data in one screen. Lets say for example 5 rows.
  • Each row has its own edit button. Lets say that the user clicks the edit button on row 3.
  • User is then redirected to the edit screen which has 4 dropdowns to edit the 4 data fields on row 3
  • User selects wanted values from the dropdown. Here is the original goal -> When user changes the value on any of the dropdowns, an icon is displayed on row 3 that the data has been edited. 

Problem is, how can i get this icon back to the original screen to the corresponding row? 


mvp_badge
MVP

Ah, ok, that's a lot more clear, thanks. The first question I would have is "how long do you want to display the icon"? If I visit the page the next day, is the icon still there?

That said, the easiest and best way is to have, in any Entity that can be created and updated by a user, four attributes:

  • CreatedOn - date/time when the record was created;
  • CreatedBy - UserId of the user creating the record;
  • ModifiedOn - date/time when the record was last modified;
  • ModifiedBy - UserId of the user modifying the record.

When the user changes the values, and these changed values are saved to the database, the ModifiedOn and ModifiedBy attributes should be updated. Then, in your overview screen, you can check whether ModifiedOn is close enough to the CurrentDateTime() (e.g. using a DiffMinutes()) and if so, display the icon.

Thanks for the reply.

I unfortunately didnt realize to mention that the data used in this app is retrieved through an REST API endpoint, so theres no outsystems database in use. The icon should be displayed until the user saves the data.

mvp_badge
MVP

Right. In that case just add a "dirty" indicator (some "IsModified" boolean) to the structure that holds the data, so you can set it when the data is changed.

You'll probably want to have that anyway, as saving the data would also be performed via REST, and you wouldn't want to "save" the records not changed.

That was my original solution for this problem. Allthough there is no empty fields in the structure where this type could be added. Is it possible to add a field to outsystems structure and just drop it off before saving the data via REST?

mvp_badge
MVP

There's a couple of approaches you could take. In no particular order:

  • Create a structure that's equal to the REST structure and add the extra boolean. Create a local list of that type. After retrieving the list from REST, assign the REST list to the new list, using mapping if needed. Alternatively, create a structure that has two attributes, one containing the original REST structure, the other the boolean.
  • Add the boolean to the REST structure. Set up the REST service so that default values aren't sent (only possible if the REST service is ok with that of course). Clear the boolean before sending.

I'd probably go for the first solution, with the structure-as-attribute, as it's imho the most maintainable.

Although your question needs to be a bit more precise but as far as I am able to understand this can be achieved by data grid 

you can refer to this doc.

https://success.outsystems.com/Documentation/How-to_Guides/Development/OutSystems_Data_Grid/How_to_use_OutSystems_Data_Grid_Web

mvp_badge
MVP

I don't see how the data grid could help in comparing two lists?

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