<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Save duplicate value with submit button</title><link>https://community.appian.com/discussions/f/user-interface/23803/save-duplicate-value-with-submit-button</link><description>Hi, 
 i have a list of items I want to save to the data. 
 The output should be ID=4, ID=5, ID=6 
 However, when submitted, it duplicates first ID: ID=4, ID=4, ID=4. 
 please help. 
 thanks</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Save duplicate value with submit button</title><link>https://community.appian.com/thread/91476?ContentTypeID=1</link><pubDate>Wed, 23 Feb 2022 19:55:33 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:02843891-f0f2-4040-bc88-6cc2eda5faaf</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Great, thanks for confirming :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Save duplicate value with submit button</title><link>https://community.appian.com/thread/91475?ContentTypeID=1</link><pubDate>Wed, 23 Feb 2022 19:54:01 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ad41e14b-f4b2-4604-98ed-ddf66ce07dcf</guid><dc:creator>kend0001</dc:creator><description>&lt;p&gt;Thanks, it works perfectly&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Save duplicate value with submit button</title><link>https://community.appian.com/thread/91474?ContentTypeID=1</link><pubDate>Wed, 23 Feb 2022 19:46:06 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:3f1520e3-636a-4a0b-8fd3-67e13c186833</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Is &amp;quot;ri!Data&amp;quot; an Array?&amp;nbsp; Because you&amp;#39;re basically telling your Submit button to write into a (generic, non-array-indexed) ID field of ri!Data, each of the values in local!list in succession.&amp;nbsp; This will have unpredictable results as-written, even if you pre-populate the array with 3 empty elements.&amp;nbsp; And if it&amp;#39;s not meant to be an array then I&amp;#39;m just lost.&lt;/p&gt;
&lt;p&gt;Going out on a limb a bit (since you didn&amp;#39;t really make this clear), I&amp;#39;m guessing what you might really want to end up with is a list of ri!Data elements where the &amp;quot;.ID&amp;quot; properties of that list end up looking like the local!list items (and would cleanly follow the number of items in local!list).&amp;nbsp; My recommended approach for that is always what I usually describe as &amp;quot;assembling your array first, then saving it into its desired location&amp;quot;.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="java"&gt;a!localVariables(
  local!list: { 4, 5, 6 },
  
  a!formLayout(
    label: &amp;quot;Form&amp;quot;,
    
    buttons: a!buttonLayout(
      primaryButtons: {
        a!buttonWidget(
          label: &amp;quot;Submit&amp;quot;,
          saveInto: {
            a!save(
              target: ri!Data,
              value: a!forEach(
                items: local!list,
                
                /* this should create a new list of dictionaries containing the above values, then (over)write them into ri!Data. */
                expression: {
                  ID: fv!item
                }
              )
            )
          },
          submit: true,
          style: &amp;quot;PRIMARY&amp;quot;
        )
      }
    )
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>