Passing record list parameters to web blocks

Passing record list parameters to web blocks

Hello all.
It's common knowledge that passing record list as parameters to _actions_ is done by reference. Inside the action if we change the record list (for example, by appending elements), those changes will be reflected in the original record list.
I was assuming that same behavior when passing record list as parameters to _web blocks_.
However, for what I have discovered (the hard way) this is not the case: when passing record list as parameters to web blocks this is done by _value_, because, inside the web block, if we change the record list those changes are not reflected in the original record list.
Can someone explain if this was done intentionally, breaking the pattern of passing record lists in parameters by reference, or if it's an issue not found yet?
Hi Tiago,

For historical reasons we have indeed a strange behavior. Ideally all the parameters should be passed be value to avoid strange side effects, but we decided to make recordlists parameters to be passed by reference for actions in the same espace to increase the efficiency of action calls with large lists.

Please consider passwing parameters by refrence an exception, and avoid side effect since they don't apply to web services, webblocks, webscreens and even public actions from other espaces.

I'm sorry you found this behaviour the hard way. I'll make sure this is properly documented in Service Studio to avoid this situation in the future.
Hello Lúcio,
Thank you for your reply.
Effectively, since my post, I've also discovered that, like you mention, for _public actions_ from other espaces the passing of record lists as parameters is also not done by reference but indeed by value.
Before I made this post I searched the forums and talked to people with more experience in outsystems, and this exceptions to record list parameter passing were not known. Everybody assumed that record lists were passed reference in all situations.
I think it is very important to mention this exceptions in the documentation so developers are aware of these exceptional behaviors. Or the other way around, the exceptional behavior is, in the local espace, passing record lists as parameter to actions is done by reference, for the sake of performance.
Best regards,
Tiago Bernardo
    I have a slightly differnt Use Case for you. I have a webservice that consumes an XML document representing a loan applicaiton. Naturally it references a list of applicants which might have lists of prior addresses lists of employers.
     I want to create a UI that "fills" in the application data structure before its sent to the web service for evaluation. Consequently, I was expecting not to use the Outsystems database to manage data, making it desirable then to pass parts of the data structure by reference... say to create/edit the list of applicants or a particular applicant's list of addreses.
    I'm new to UI work having sent most of my career on the server side of things. What's the right way to accomplish what I want to do?