<?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>Only fields with scalar types can be indexed from an array.</title><link>https://community.appian.com/discussions/f/data/18587/only-fields-with-scalar-types-can-be-indexed-from-an-array</link><description>Hello 
 I am facing below issue 
 I created local called 
 local!gridDataStructure: &amp;#39;type!{urn:com:appian:types}CDT&amp;#39;( 
 role:{1,2,3} 
 . 
 . 
 . 
 . 
 . 
 ) 
 role is type of list of integer 
 
 
 When i try to print as local!gridDataStructure.role it</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Only fields with scalar types can be indexed from an array.</title><link>https://community.appian.com/thread/73203?ContentTypeID=1</link><pubDate>Thu, 09 Apr 2020 13:24:59 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:a9eca248-a636-4351-bed3-314fd7531cec</guid><dc:creator>Peter Lewis</dc:creator><description>&lt;p&gt;You might need to do something with a!forEach() and update&amp;nbsp;just the value of interest. For example, suppose I want to update the list for the second item - here&amp;#39;s an expression that might work:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!test: {
    &amp;#39;type!{urn:com:appian:types:PDL}PDL_TestNestedCDT&amp;#39;(
      list:{1,2,3}
    ),
    &amp;#39;type!{urn:com:appian:types:PDL}PDL_TestNestedCDT&amp;#39;(
      list: {4,5,6}
    )
  },
  {
    a!richTextDisplayField(
      value: tostring(local!test)
    ),
    a!buttonArrayLayout(
      buttons: {
        a!buttonWidget(
          label: &amp;quot;Test&amp;quot;,
          saveInto: a!save(
            target: local!test,
            value: a!forEach(
              items: local!test,
              expression: if(
                fv!index = 2 /* only update row 2 */,
                &amp;#39;type!{urn:com:appian:types:PDL}PDL_TestNestedCDT&amp;#39;(
                  list: {7,8,9}
                ),
                fv!item
              )
            )
          )
        )
      }
    )
  }
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Only fields with scalar types can be indexed from an array.</title><link>https://community.appian.com/thread/73198?ContentTypeID=1</link><pubDate>Thu, 09 Apr 2020 09:28:21 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:fda04885-73bb-41f4-9484-f986a394e7cc</guid><dc:creator>Shubham Aware</dc:creator><description>&lt;p&gt;Hey Peter,&lt;br /&gt;&amp;nbsp;I am able to print by using this&lt;/p&gt;
&lt;p&gt;&amp;nbsp;index(index(local!test, 1, {}), &amp;quot;list&amp;quot;)&lt;br /&gt;&lt;br /&gt;But i am facing difficulties in writing because&lt;/p&gt;
&lt;p&gt;I can write to it like&amp;nbsp; local!test[1].list&lt;br /&gt;&lt;br /&gt;Can you suggest something?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Only fields with scalar types can be indexed from an array.</title><link>https://community.appian.com/thread/73193?ContentTypeID=1</link><pubDate>Thu, 09 Apr 2020 05:47:27 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ef926107-ec83-4bc4-a7ff-559defb70d8f</guid><dc:creator>Shubham Aware</dc:creator><description>&lt;p&gt;Thanks Peter&lt;br /&gt;It&amp;#39;s working now&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Only fields with scalar types can be indexed from an array.</title><link>https://community.appian.com/thread/73187?ContentTypeID=1</link><pubDate>Wed, 08 Apr 2020 22:20:04 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:bcea07fc-2865-4897-b132-8fc7ebbeef1e</guid><dc:creator>Peter Lewis</dc:creator><description>&lt;p&gt;Usually this happens if you have an array of arrays. Is it possible that local!gridDataStructure also contains an array of CDT? Here&amp;#39;s an example:&amp;nbsp;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!test: {
    &amp;#39;type!{urn:com:appian:types:PDL}PDL_TestNestedCDT&amp;#39;(
      list:{1,2,3}
    ),
    &amp;#39;type!{urn:com:appian:types:PDL}PDL_TestNestedCDT&amp;#39;(
      list: {4,5,6}
    )
  },
  index(index(local!test, 1, {}), &amp;quot;list&amp;quot;)
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This will work because I first index into the first item of &amp;quot;PDL_TestNestedCDT&amp;quot;, then index into &amp;quot;list&amp;quot;. However, it wouldn&amp;#39;t be possible to directly enter local!test.list because that results in a list of lists.&lt;/p&gt;
&lt;p&gt;If you need to display or perform a calculation with this, you can also get around this by using a!forEach() like this:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!test: {
    &amp;#39;type!{urn:com:appian:types:PDL}PDL_TestNestedCDT&amp;#39;(
      list:{1,2,3}
    ),
    &amp;#39;type!{urn:com:appian:types:PDL}PDL_TestNestedCDT&amp;#39;(
      list: {4,5,6}
    )
  },
  a!forEach(
    items: local!test,
    expression: fv!item.list
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Only fields with scalar types can be indexed from an array.</title><link>https://community.appian.com/thread/73183?ContentTypeID=1</link><pubDate>Wed, 08 Apr 2020 21:18:38 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:4da7520c-1ef3-48b7-bc8b-efd8c2da664f</guid><dc:creator>Danny Verb</dc:creator><description>&lt;p&gt;Can you also attach the SAIL used to index into the CDT?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>