How to update multiple records on a single click?
Question
Application Type
Reactive

Hi,

I bootstrapped an excel sheet having 30,000 + records in it. I just want to run a loop who replace "ABC" with "XYZ". I wrote the simple logic for it and ran it. It executed but when I checked 50 records are updated. I don't understand why remaining records are not updated. Please guide my guys here.

Output URL : 

https://personal-dxyedsv3.outsystemscloud.com/TestApp1/Screen1?_ts=637651715018330287

On clicking on Button I update the Value. And you can see 1st 50 records are updated not remaining one.





Thanks

Solution

So I did a demo on my side, so, what I did was

1- create 2 buttons to change to ABC and XYZ, just for demonstration

2-In each button I have an action, that calls a server action, in this case, I have a server action that changes "ABC" to "XYZ"

3- Inside the server action, you will call the aggregate of the list, all the list, and you update all the records. Important! when you want to do a server action it's better in terms of performance to do it in a server action


You can try here on my link

https://marcio-carvalho4.outsystemscloud.com/CHnagingRecords/List1s?_ts=637651568611014915

Ps: try to see what is returning geturls.count and you don't need the max iterations, even the start index. That will do a for each and update everything on your aggregate. And let me see what aggregate and where are u using that aggregate and the action that is updating the records. I think you are changing just per pagination. If you see what that geturls.count retrieves, you are going to see that is changing the records based on the max records on the aggregate retrieved :)

kind regards,

Márcio

CHnagingRecords.oml

Hi Khris,


without looking at your code this is just guessing, but it looks like you are passing the list of currently displayed  records in your screen one at a time to server action to update them.  So several things are wrong here.

First of all what you have already spotted, only the records currently showing on your screen are going to be updated, as that is the only list you are iterating.  

But also, let's say you display 50, then this code will make 50 consecutive server calls instead of 1, which is horrible for performance.

So, as Marcio is suggesting, you should have a single server call, and inside the server action going over all the to be updated records on your database, not just the ones currently shown on your screen.  

I would like to expand on Marcio's response with 2 extra things to consider :

When you are talking about many records to be updated in the same way, it might be worth doing a bulk update with an SQL widget instead of an aggregate followed by a loop/update.

When you are talking about even more records, you might have to think about server timeouts, and might have to put your update logic inside a timer, and just wake the timer at button press.

In your case, 30.000 records, i would definitely look at using an sql bulk update, but i guess a timer is not really necessary.

Dorine

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