<?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>Merge function usage with dynamic list</title><link>https://community.appian.com/discussions/f/rules/30325/merge-function-usage-with-dynamic-list</link><description>Hello techies, 
 
 I need to use the merge() function on a dynamic list but it isn&amp;#39;t proving easy. 
 Please check the following code snippet and suggest applying it on the dynamic list local!a.b 
 
 a!localVariables( local!a: { { a: 1, b: { 1, 2, 3 }</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Merge function usage with dynamic list</title><link>https://community.appian.com/thread/120613?ContentTypeID=1</link><pubDate>Tue, 17 Oct 2023 05:16:23 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:0f889c42-58e2-47a7-baae-44bf7814c7bb</guid><dc:creator>tushark6475</dc:creator><description>&lt;p&gt;I guess, there is always some space for optimization.&amp;nbsp;&lt;span class="emoticon" data-url="https://community.appian.com/cfs-file/__key/system/emoji/1f609.svg" title="Wink"&gt;&amp;#x1f609;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merge function usage with dynamic list</title><link>https://community.appian.com/thread/120588?ContentTypeID=1</link><pubDate>Mon, 16 Oct 2023 14:31:20 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:a5d013be-cc9c-4fb7-ab22-0f98d6d2c7b4</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;A small optimization&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!a: {
    { a: 1, b: { 1, 2, 3 } },
    { a: 2, b: { &amp;quot;asdf&amp;quot;, 5, 6 } },
    { a: 1, b: { 7, 8 } }
  },
  a!forEach(
    items: enumerate(count(local!a)),
    expression: a!localVariables(
      local!index: fv!index,
      a!forEach(
        items: local!a.b,
        expression: index(fv!item, local!index, &amp;quot;&amp;quot;)
      )
    )
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merge function usage with dynamic list</title><link>https://community.appian.com/thread/120586?ContentTypeID=1</link><pubDate>Mon, 16 Oct 2023 14:16:20 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:d4042d69-3887-4ae5-9524-b5945d9a4cb5</guid><dc:creator>Peter Lewis</dc:creator><description>&lt;p&gt;Yeah this looks like a good outcome! For what it&amp;#39;s worth, since a!forEach() came out, I have entirely stopped using the merge() function. You can generally achieve anything you needed to from merge() with a!forEach(), and a!forEach() is much easier to debug or set up complex logic.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merge function usage with dynamic list</title><link>https://community.appian.com/thread/120583?ContentTypeID=1</link><pubDate>Mon, 16 Oct 2023 13:45:46 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:fbbe0fe3-b9c2-4e52-8fd4-10405cb2abd6</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;merge() does not work here as it requires the individual lists to be separate parameters instead of a list of lists.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merge function usage with dynamic list</title><link>https://community.appian.com/thread/120580?ContentTypeID=1</link><pubDate>Mon, 16 Oct 2023 12:41:27 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c690f7f8-3305-4585-b038-fefdbe1be430</guid><dc:creator>tushark6475</dc:creator><description>&lt;p&gt;&lt;a href="https://stackoverflow.com/help/how-to-ask"&gt;stackoverflow.com/.../how-to-ask&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merge function usage with dynamic list</title><link>https://community.appian.com/thread/120579?ContentTypeID=1</link><pubDate>Mon, 16 Oct 2023 12:32:26 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c13952c7-b00b-45a8-8a08-7823eea32ef5</guid><dc:creator>tushark6475</dc:creator><description>&lt;p&gt;In that case, this will work for you -&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;img alt=" " src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/15/pastedimage1697459499587v1.png" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!a: {
    { a: 1, b: { 1, 2, 3 } },
    { a: 2, b: { &amp;quot;asdf&amp;quot;, 5, 6 } },
    { a: 1, b: { 7, 8 } }
  },
  a!forEach(
    items: enumerate(count(local!a.b)) + 1,
    expression: a!localVariables(
      local!index: fv!item,
      a!forEach(
        items: local!a.b,
        expression: if(
          local!index &amp;gt; count(fv!item),
          &amp;quot;&amp;quot;,
          fv!item[local!index]
        )
      )
    )
  )
)&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Note - Here I am assuming that you require the output in the &amp;quot;List of Variant&amp;quot; type. If you want output as a &amp;quot;list of text&amp;quot; or only 3 values then wrap the inner forEach() in the joinArray() with a separator &amp;quot;,&amp;quot;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merge function usage with dynamic list</title><link>https://community.appian.com/thread/120578?ContentTypeID=1</link><pubDate>Mon, 16 Oct 2023 12:14:40 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:d41aebdf-8b78-4222-8b83-e3451b22dcf3</guid><dc:creator>TJ</dc:creator><description>&lt;p&gt;Hi Tushar,&lt;/p&gt;
&lt;p&gt;Thank you for your response. However,&lt;/p&gt;
&lt;p&gt;I am looking for the output&amp;nbsp;&lt;span&gt;{{1, &amp;quot;asdf&amp;quot;, 7}, {2, 5, 8}, {3, 6, null}} and not the result of foreach&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merge function usage with dynamic list</title><link>https://community.appian.com/thread/120577?ContentTypeID=1</link><pubDate>Mon, 16 Oct 2023 12:14:03 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:7445ee78-de65-4fbd-95ac-eba4d062df6d</guid><dc:creator>TJ</dc:creator><description>&lt;p&gt;Hi Stefan,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Apologies for the misunderstanding, I am looking for the following merged output but using the variable local!a.b and not the values.&lt;/p&gt;
&lt;div class="SplitPaneLayout---pane SplitPaneLayout---secondary_pane"&gt;
&lt;div class="SplitPaneLayout---contents"&gt;
&lt;div class="TabButtonGroup---tab_group TabButtonGroup---inHeaderBodyLayout"&gt;
&lt;div class="TabButtonGroup---tab_contents_container TabButtonGroup---flush"&gt;
&lt;div class="ContentLayout---content_layout ContentLayout---padding_less"&gt;
&lt;div class="SectionLayout2---sectionLayout SectionLayout2---margin_above_none"&gt;
&lt;div class="CollapsibleElement---collapsible"&gt;
&lt;div class="SectionLayout2---section_contents SectionLayout2---margin_below_standard"&gt;
&lt;div class="ColumnArrayLayout---column_layout ColumnArrayLayout---standard_spacing appian-context-last-in-list"&gt;
&lt;div class="ColumnLayout---column ColumnLayout---column_padding_standard ColumnLayout---align_start ColumnLayout---top ColumnLayout---width_auto ColumnLayout---stack_when_phone appian-context-last-in-list"&gt;
&lt;div class="FieldLayout---field_layout FieldLayout---margin_below_none FieldLayout---margin_above_none FieldLayout---inColumnArrayLayout appian-context-last-in-list"&gt;
&lt;div class="FieldLayout---input_below"&gt;
&lt;p class="ParagraphText---richtext_paragraph ParagraphText---default_direction ParagraphText---align_start elements---global_p"&gt;{{1, &amp;quot;asdf&amp;quot;, 7}, {2, 5, 8}, {3, 6, null}}&lt;/p&gt;
&lt;p class="ParagraphText---richtext_paragraph ParagraphText---default_direction ParagraphText---align_start elements---global_p"&gt;&lt;/p&gt;
&lt;p class="ParagraphText---richtext_paragraph ParagraphText---default_direction ParagraphText---align_start elements---global_p"&gt;So, from the original query;&lt;/p&gt;
&lt;p class="ParagraphText---richtext_paragraph ParagraphText---default_direction ParagraphText---align_start elements---global_p"&gt;&lt;span&gt;merge({ 1, 2, 3 }, { &amp;quot;asdf&amp;quot;, 5, 6 }, { 7, 8 }) works as the literal values results in desired output&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p class="ParagraphText---richtext_paragraph ParagraphText---default_direction ParagraphText---align_start elements---global_p"&gt;&lt;span&gt;however,&amp;nbsp;merge(local!a.b[1], local!a.b[2], local!a.b[3]), does not work with the exact same values used in list of variants&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="SplitPaneLayout---separator SplitPaneLayout---horizontal SplitPaneLayout---resizable"&gt;
&lt;div class="SplitPaneLayout---default_direction SplitPaneLayout---collapse_control_parent SplitPaneLayout---parent_horizontal SplitPaneLayout---collapse_control_parent_right"&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merge function usage with dynamic list</title><link>https://community.appian.com/thread/120558?ContentTypeID=1</link><pubDate>Mon, 16 Oct 2023 07:21:02 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:52539dd7-94c3-4fc9-acd6-574ac5c7037c</guid><dc:creator>tushark6475</dc:creator><description>&lt;p&gt;I guess, this is you are looking for -&amp;nbsp;&lt;br /&gt;&lt;img src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/15/pastedimage1697440810588v1.png" alt=" " /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!a: {
    { a: 1, b: { 1, 2, 3 } },
    { a: 2, b: { &amp;quot;asdf&amp;quot;, 5, 6 } },
    { a: 1, b: { 7, 8 } }
  },
  a!forEach(
    items: local!a,
    expression: fv!item.b
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merge function usage with dynamic list</title><link>https://community.appian.com/thread/120556?ContentTypeID=1</link><pubDate>Mon, 16 Oct 2023 06:23:00 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ea1c866f-dbb7-4086-a53c-b91a35dabb84</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;I still do not have a clear idea what the final output of this operation should look like. Your input data structure is:&lt;/p&gt;
&lt;p&gt;&lt;span&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp; { a: 1, b: { 1, 2, 3 } },&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp; { a: 2, b: { &amp;quot;asdf&amp;quot;, 5, 6 } },&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp; { a: 1, b: { 7, 8 } }&lt;/span&gt;&lt;br /&gt;&lt;span&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Now, what is the output?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merge function usage with dynamic list</title><link>https://community.appian.com/thread/120551?ContentTypeID=1</link><pubDate>Mon, 16 Oct 2023 03:00:20 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:27763218-a2ca-4747-b4b2-0b3156437e74</guid><dc:creator>TJ</dc:creator><description>&lt;p&gt;Hi Stefan,&lt;/p&gt;
&lt;p&gt;The intended outcome is&amp;nbsp;&lt;span&gt;merge({ 1, 2, 3 }, { &amp;quot;asdf&amp;quot;, 5, 6 }, { 7, 8 }), somehow using local!a.b variable.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The use case is to build a&amp;nbsp;table with columns local!a.a and dynamic rows based on combination of local!a.b&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merge function usage with dynamic list</title><link>https://community.appian.com/thread/120540?ContentTypeID=1</link><pubDate>Sun, 15 Oct 2023 13:42:21 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:6d7e8005-486a-4f51-9309-5c3e9fc81df8</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;What is the intended outcome? And, why do you &amp;quot;need&amp;quot; to use the merge function?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>