First List element is getting replaced by last list element

First List element is getting replaced by last list element

  
Hello,

I am preparing one record list by appending values from the result of "String_Split" function.

I am passing that RecordList to "RecordListToXML" control.

I am geting XML with correct no of nodes but what I see inside XML is last node's contents matches with first node and first node is not there at all i.e my first element is getting replaced by last element.

Here is an example :

<trans-unit>
<id>4</id>
<ctype>lb</ctype>
<recordvalue>• Garantie und technische Hotline</recordvalue>
</trans-unit>
<trans-unit>
<id>2</id>
<ctype>lb</ctype>
<recordvalue>• LogitechΠWebkamera-Software auf CD
</recordvalue>
</trans-unit>
<trans-unit>
<id>3</id>
<ctype>lb</ctype>
<recordvalue>• Handbuch
2 Jahre </recordvalue>
</trans-unit>
<trans-unit>
<id>4</id>
<ctype>lb</ctype>
<recordvalue>• Garantie und technische Hotline</recordvalue>
</trans-unit>

Please advice.

Thanks and Regards,
Suraj Borade
Hi there Suraj,

I believe this can be a number of things, but most likely it's something to do with the way it's coded.

Would you please isolate the issue in a module that could publish in a personal edition? People in the community can then can have a look at it and better help you :)

Cheers!
Hi Mario,

Thanks for the reply.

I have attached an OML.

Here, inside generate XML action, I am splitting string and assigning to the record list. I want to convert that record list into XML but my first element is getting replaced by last element. 

Please have a look.

Thanks.

-- Suraj 
Hi Suraj,

You can never ever ever use the RecordList.Current in a ListAppend to the same RecordList. Ever. And yes, I do think Service Studio should signal a Warning or even an Error. Create a local variable, and assign + ListAppend that and your problems will be fixed.
Good Morning Kilian sir,

Your solution perfectly worked. You really have in depth knowledge of OutSystems platform. I and my team really appreciate it.

Meanwhile I searched for documentation of ListAppend functionality but I didn't get explanation about this issue.

Will you please explain why should we avoid appending RecordList.Current to the same RecordList?

Thanks again.

Regards,
Suraj Borade

Hi Suraj,

It's one of these things that have to do with how the platform is implemented. I'm not sure why it works like that, an OutSystems engineer could probably tell us more. I just find it slightly baffling that there's no warning in the documentation or in Service Studio, as it is a common error to make. I've created an idea to have Service Studio give a warning or error if you try to do this. You can vote for it :).
Thanks a lot sir.

I have posted my views for this idea.


I'm failing to see why service studio should give a warning/error. error most definately not.
a warning I doubt, I can imagine there are use-cases for it...

J.,

The reason why Service Studio should warn is that it's something that seems very intuitive to do, but doesn't work (it has never worked). Every newbie falls in this trap. ListAppending the Current of the recordlist you're appending to fails (or rather, leads to unexpected/unpredictable) results. You don't think the platform should warn you when you're trying to do something that doesn't work?
I agree to disagree :)

Help:

The ListAppend action is a System Action that adds an element to the end of a list. The input list is effectively modified but the current element of this list is not changed.

Variables of List data type have a reference to the values, so don't contain a copy of the elements.


So imho, it does what it does....it adds the current, but current is never changed....
which maybe strange at first, but to me, it's logical.

I see what you mean. Still, about every collegue of mine fell into this pitfall, and before that I did. I still think it's nice to give a warning :).