<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: Best Practice for filling a List in a loop</title><link>https://answers.axonivy.com/questions/105/best-practice-for-filling-a-list-in-a-loop</link><description>&lt;p&gt;I'm using Xpert.ivy Designer 5.1.0 (Lauberhorn) S6. I tried to fill a List in a loop: &lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;In a form I ask the user, how many entries the list will have (numberOfIterations)&lt;/li&gt;
&lt;li&gt;With an Alternative Switch element I'm ensuring, that the following steps are executed as often as the defined number of iterations:&lt;/li&gt;
&lt;li&gt;In a form I ask the user for the attributes of the list entry (attribute one, attribute two)&lt;/li&gt;
&lt;li&gt;In three different variants I add the new list entry to the list. Only the most time consuming variant works. The other variants don't work as expected. I suppose, this is a bug.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;To better understand, please watch the &lt;a href="http://youtu.be/PAn626HnR-Q?hd=1"&gt;screencast on YouTube&lt;/a&gt; (2 minutes).&lt;/p&gt;
&lt;p&gt;An answer until 25.11. evening would be very appreciated.&lt;/p&gt;
&lt;p&gt;[EDIT]: &lt;strong&gt;Here the &lt;a href="https://dl.dropboxusercontent.com/u/158270/TEMP_ZHAW_HS13/FillListInLoop.iar"&gt;link to the iar-File&lt;/a&gt; for testing.&lt;/strong&gt;&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/105/best-practice-for-filling-a-list-in-a-loop" rel="self"></atom:link><language>en</language><lastBuildDate>Fri, 22 Nov 2013 13:28:23 -0500</lastBuildDate><item><title>Answer by Björn</title><link>https://answers.axonivy.com/questions/105/best-practice-for-filling-a-list-in-a-loop/113</link><description>&lt;p&gt;With the input of Daniel Oechslin I was able to make a simple solution without the code element. I use the funtion deepClone to generate a new listEntry-Object each run. See the picture below.
&lt;img alt="DeepClone" src="/upfiles/2013-11-22_13h27_17.png"&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Björn</dc:creator><pubDate>Fri, 22 Nov 2013 13:28:23 -0500</pubDate><guid>https://answers.axonivy.com/questions/105/best-practice-for-filling-a-list-in-a-loop/113</guid></item><item><title>Answer by Daniel Oechslin</title><link>https://answers.axonivy.com/questions/105/best-practice-for-filling-a-list-in-a-loop/109</link><description>&lt;p&gt;Hi Björn&lt;/p&gt;
&lt;p&gt;I added this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;import fillListInLoop.ListEntry;&lt;/p&gt;
&lt;p&gt;in.demoListEntry= new ListEntry();&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;in a script step between your XOR and the Dialog (Collect attributes for one entry in the demo list)&lt;/p&gt;
&lt;p&gt;It works fine and I don't see any extra time consuming factor. Please remember that you can disable the animation. A scriptstep animation is shown slower by Default.&lt;/p&gt;
&lt;p&gt;The correct behavior of this Addition would be to have a result as the following:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;ListEntry(attributeOne=a, attributeTwo=aa)&lt;/p&gt;
&lt;p&gt;ListEntry(attributeOne=b, attributeTwo=bb) &lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Cheers to the ZHAW&lt;/p&gt;
&lt;p&gt;&lt;img alt="elemenToList" src="http://s17.postimg.org/57p8gpk6n/add_Element_To_List.jpg"&gt;&lt;/p&gt;
&lt;p&gt;The scheme shown in the Ivy.Designer:&lt;/p&gt;
&lt;p&gt;&lt;img alt="Screenshot" src="http://s22.postimg.org/3n6ix7ydd/screen.jpg"&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Daniel Oechslin</dc:creator><pubDate>Fri, 22 Nov 2013 11:37:02 -0500</pubDate><guid>https://answers.axonivy.com/questions/105/best-practice-for-filling-a-list-in-a-loop/109</guid></item><item><title>Answer by Daniel Oechslin</title><link>https://answers.axonivy.com/questions/105/best-practice-for-filling-a-list-in-a-loop/106</link><description>&lt;p&gt;Hi Björn&lt;/p&gt;
&lt;p&gt;Concerning your second run (Add list entry to demo list I (doesn't work)):
I think the behavior you scripted is what it should be. The problem is, that you use the same 'in.demoListEntry' twice. You don't instatiate a new one before entering the new Dialog data. You should add something like:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;DemoListEntry demoListEntry= new DemoListEntry();&lt;/p&gt;
&lt;p&gt;demoListEntry.attribute1= "b";&lt;/p&gt;
&lt;p&gt;demoListEntry.attribute2= "bb";&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The same Problem should apply to you third run.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Daniel Oechslin</dc:creator><pubDate>Fri, 22 Nov 2013 11:05:36 -0500</pubDate><guid>https://answers.axonivy.com/questions/105/best-practice-for-filling-a-list-in-a-loop/106</guid></item></channel></rss>