Why aren't RecordLists and the Source Record List kept in sync?

Here I have a RecordList called "ListCriteria" attached to a variable SearchCriteria that is a list of Search.


in the web screen, if the user clicks delete, i want to remove that record:

In the server action for delete, if I simply remove the record from SearchCriteria, then the values entered into the other form fields in the list get erased. I have to manually tell outsystems to copy the values from the list to the searchcriteria, then remove the record, then reassign the searchcriteria to the list.

This doesn't make sense to me. It seems like if I say a RecordList is attached to a list of something, then I change that list of something, it should reflect that change in the web. Also, if I update a value of a record in a list, then that change should be reflected in the underlying list.

However, the behavior is both the RecordList and the underlying Variable list operate independently. Since that's the case, why do I even need to assign a record list to a list?

This is confusing and I'm not sure how to make sense of it or if I'm just doing it wrong.

I am not sure if I understood your question Right but I will try to Answer.

I guess it only  helps to create a structure, to Avoid errors for variable types (also to determine if its basic or complex datatype).

Also Web-apps consume less resource if they are don't keep updating the page for record changes in back-end  unless explicitly asked for ( If the Design needs it )


Also you have Ajax and Forge Components like Firebase to help you with Long-polling or web-socket if you want to go that way.



Hi PJ M,

You do not mention if your "delete" link is using method Submit or Ajax Submit, but I'm guessing you are using Ajax Submit. When using Ajax, the browser will only refresh the portions of the screen you explicitly tell it to, using the Ajax Refresh tool.

In your case, you are changing the source of the data, but if you fail to re-render it on the browser, it will still display the old data.

Now, in your case, it seems you can simply manipulate the ListCriteria.List using the ListDelete built-in action and you will see how this will automatically perform the Ajax refresh.

I strongly recommend you go to the online training (again?), as Table/ListRecords are covered in lessons Widgets I and Widgets II, respectively, and the Ajax behaviour is covered in the Screen Lifecycle: Ajax Interaction lesson.

Hope this helps!

Jorge Martins wrote:

Hi PJ M,

You do not mention if your "delete" link is using method Submit or Ajax Submit, but I'm guessing you are using Ajax Submit. When using Ajax, the browser will only refresh the portions of the screen you explicitly tell it to, using the Ajax Refresh tool.

In your case, you are changing the source of the data, but if you fail to re-render it on the browser, it will still display the old data.

Now, in your case, it seems you can simply manipulate the ListCriteria.List using the ListDelete built-in action and you will see how this will automatically perform the Ajax refresh.

I strongly recommend you go to the online training (again?), as Table/ListRecords are covered in lessons Widgets I and Widgets II, respectively, and the Ajax behaviour is covered in the Screen Lifecycle: Ajax Interaction lesson.

Hope this helps!

I thought his question was more like why do I have to use Ajax manually ? Why doesn't the platform keep the data in sync with web and backend automatically(without any ajax). Like in the Angular Js or Firebase real time data


"Why doesn't the platform keep the data in sync with web" - It does on mobile, but that's different technology.

I am doing the AJAX. Here's the handler for the DELETE link to remove one row from what is displayed on the web page:

Notice how I have to copy the web list back into the source list. Basically, I have to rebuild the source record list each time a change is made to the web record list. Intuitively, it seems like I should only need to do ListRemove on the source record list and then the AJAX refresh.


Alternatively, I don't even need the Source Record List in this case, I could do all my work with the Web record list alone, however, OutSystems requires me to specify a source record list for my web record list. If I only had to specify what TYPE of data is in the list, I wouldn't need the source record list at all and I could do everything with the web record list.

Are you trying to delete the data Just from the front end screen or In the back-end too (I don't see a Delete action used here )?

If you are deleting in the back end too then after calling the Delete Action use "Refresh Data" Action on the Aggregate  used in preparation just before the Ajax Refresh instead of using the ListClear, ListAppendAll and ListRemove.

coder kamath wrote:

Are you trying to delete the data Just from the front end screen or In the back-end too (I don't see a Delete action used here )?

Just the front end, there's no aggregate and the data in the web list isn't saved anywhere it's only used in memory to construct a where clause. 

Intuitively, I thought I would just delete the row from the web list and call ajax refresh on the web list, but if I do that, then because the source list of criteria for the where clause isn't in sync, then when the web list refreshes, all the rows show default values.

I want to save the values the user enters, and they may enter 4 rows of query parameters, then delete the 2nd row. in that case, I want row 1, 3, and 4 to remain.


I am afraid that Outsystems web Isn't built for these Kind of Situation.

Although as Killian Suggested you can do this with Mobile as  its working on Different Technology

Whatever you are doing now might be a Good way to do it.

If you are trying to Avoid Network to and fro, You might have to write custom components to Achieve this or Use custom Html using Expression tags and Javascript to do it completely in front end.


Also You might try adding these as a Idea, someone might pick it up and build it for future.


Hi PJ M,

If you only want to affect what's displayed on screen, you can do what I told you and is explained in the Screen Lifecycle: Ajax Interaction lesson:

Now, in your case, it seems you can simply manipulate the ListCriteria.List using the ListDelete built-in action and you will see how this will automatically perform the Ajax refresh.

This will update the list that is being used by the List Records to render it. It relies on Ajax to update the List Records with just the required change and has no impact on the Source Record List.

Please try it and let us know if it behaves as needed.

I can't just do the ListRemove because when i refresh it, it brings back data in the underlying Source List and then all the values on the web return to the default. I have to copy the web list to the source list, THEN remove the item the user deletes on the web.


This might be resolved by allowing us to create a Web List based on an Entity, rather than a LIST of entities. Then we just use the Record List everywhere and have one list to deal with.

PJ M,

Why do you need to refresh the ListCriteria at all?? You don't need to, the ListRemove* already did it for you.

* sorry, earlier I used the wrong name ListDelete for the built-in action, and that action doesn't exist

Hi PJ M,

Following what Jorge said.

When you Refresh a List/Table Records in the screen, it will be rebuilt from scratch, and so, it will fetch the source again.
If you Ajax Refresh a single ROW of a List/Table Records, this will not happen. That line alone will be rebuild, and the data used will be the one already present in the LIst of the List/Table Records, not in the source. The source will not be fetched.

List operations performed in a List of a List/Table Records will have the effect of affecting the specified line(s) alone, and an Ajax Refresh will be performed on those lines alone. 

So, you don't need to Refresh the List/Table Records, as this is not necessary and the effect will be that the source will be fetched again.

Cheers.

EDIT:

In general, I would use the Source only to initialize the List/Table records and then use its list to perform any operation, including saving/updating to Database if required.
If for some reason, you still need to keep the source updated, you can remove from both lists (Source List and List/Table Records List), that will end in a better UX experience for the user, as the Table will not be entirely refreshed.

Okay, that is a new path to take!  I was AjaxRefreshing the entire list records, not just the row!  Let me try that and report back.

Solution

PJ M,

Do not use the Ajax Refresh tool at all!

On your action flow, remove the ListClear, ListAppendAll and ListCriteria tools (your flow should just have the Start, ListRemove and End tools).

Now, click on ListRemove and change the List input parameter to be ListCriteria.List. Your ListRemove icon should have changed to the regular Action orange-circle icon with the Ajax Refresh two-blue-arrows icon inside.

That's it...

Solution

THAT WORKS!!!!  OMG! Thank you so much! You've been so patient walking me through this, all of you! I finally get it! Makes me soooo happy!