<?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>Dynamic CDT</title><link>https://community.appian.com/discussions/f/new-to-appian/28493/dynamic-cdt</link><description>Hi All, Is there any way to create the fields dynamically in cdt and then assign values. 
 I have a use case, User will be uploading a excel and i need to show the excel data in grid format (excel can be different),So for that i am using readexceldata</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Dynamic CDT</title><link>https://community.appian.com/thread/142628?ContentTypeID=1</link><pubDate>Mon, 11 Nov 2024 08:41:29 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:07d252b0-a9f1-4d67-abcf-a0cd715952ba</guid><dc:creator>iswaryan3520</dc:creator><description>&lt;p&gt;Thanks. I understood yet if there were a way it would been easy right.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamic CDT</title><link>https://community.appian.com/thread/142619?ContentTypeID=1</link><pubDate>Sun, 10 Nov 2024 11:43:16 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:609cf333-1eb8-4a1d-92ed-e4d2e166d504</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;Trying to import Excel files with no clear structure is inherently difficult and prone to errors.&lt;/p&gt;
&lt;p&gt;Again, what I do for the first step, is to do a full raw import without looking at any structure. The logic comes in the second step. You just have to make sure that your database staging table has enough columns.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamic CDT</title><link>https://community.appian.com/thread/142618?ContentTypeID=1</link><pubDate>Sun, 10 Nov 2024 09:59:03 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:4f7ddb9e-fc00-4161-9a21-a1ff37115ada</guid><dc:creator>iswaryan3520</dc:creator><description>&lt;p&gt;Thanks for your reply Stefan. First with for each I didn&amp;#39;t know which data I should use, i.e for looping over with data local!excelData from second row or to use local!headers.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;So for excel import what I understand from you is I should directly insert the data from first row i&lt;span style="font-family:inherit;"&gt;.e from headers into the staging table right. I am trying that. I couldn&amp;#39;t find a way since my excel is dynamic which will have different headers columns and count of the columns will change each time.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamic CDT</title><link>https://community.appian.com/thread/142617?ContentTypeID=1</link><pubDate>Sun, 10 Nov 2024 09:26:15 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:35a4dd3c-e72f-45d9-9300-0d9a68d54b47</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;Sure. foreach() creates one item for each input item. This means that you will get ONE new map for each item in your local!excelData. It will NOT append fields to the same map.&lt;/p&gt;
&lt;p&gt;Appian uses a functional approach for expressions that includes immutability of variables.&lt;/p&gt;
&lt;p&gt;I do my Excel imports in a different way. First I import the file to a staging table with the fields named like in Excel (A, B, C, ...) and the data types are just varchars, then I run a stored procedure that does the necessary data transformation into the final table.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamic CDT</title><link>https://community.appian.com/thread/142615?ContentTypeID=1</link><pubDate>Sat, 09 Nov 2024 16:38:51 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:004318da-9a69-4182-85fc-b31a15c590f2</guid><dc:creator>iswaryan3520</dc:creator><description>&lt;p&gt;Hi &lt;a href="/members/stefanhelzle0001"&gt;Stefan Helzle&lt;/a&gt;&amp;nbsp;I tried with the code you gave. I got&amp;nbsp;&amp;nbsp;{a!map(&amp;#39;Mentee GGID&amp;#39;: &amp;quot;9008752&amp;quot;), a!map(&amp;#39;Enter Mentor name&amp;#39;: &amp;quot;Harikrishnan&amp;quot;)} only 2 fileds I thinks that is because i have 2 data row but the column are 25. Can you help me understand what i did wrong?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  /* Step 1: Read the data from the Excel file */
  local!excelData: index(
    index(
      readExcelSheet(
        excelDocument: ri!document,
        sheetNumber: 0,
        startRow: 2,
        numberOfColumns: 0
      ),
      &amp;quot;result&amp;quot;,
      null
    ),
    &amp;quot;values&amp;quot;,
    null
  ),

  /* Step 2: Extract headers from the first row */
  local!headers: index(
    index(
      readExcelSheet(
        excelDocument: ri!document,
        sheetNumber: 0,
        startRow: 1,
        numberOfColumns: 0
      ),
      &amp;quot;result&amp;quot;,
      null
    ),
    &amp;quot;values&amp;quot;,
    null
  ),
  local!firstRow:index(local!headers,1,null),

  /* Step 3: Map headers to each row’s values and prepare for database insert */
  local!rowsToInsert: a!forEach(
    items: local!excelData,
    expression: a!update(
      a!map(),
      local!firstRow[fv!index],
      fv!item[fv!index]

    )
  ),


  local!rowsToInsert


)
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamic CDT</title><link>https://community.appian.com/thread/111795?ContentTypeID=1</link><pubDate>Wed, 26 Apr 2023 10:26:39 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:11d19df6-aea8-4e12-81ed-234fa387c0ef</guid><dc:creator>sivasuryap0002</dc:creator><description>&lt;p&gt;Thanks , it worked.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamic CDT</title><link>https://community.appian.com/thread/111756?ContentTypeID=1</link><pubDate>Tue, 25 Apr 2023 18:15:12 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:906481e0-1c7c-41f6-a1d7-83c2827c2957</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;Just apply some magic ;-)&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!update(
  a!map(),
  &amp;quot;new_field&amp;quot;,
  &amp;quot;new_value&amp;quot;
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamic CDT</title><link>https://community.appian.com/thread/111755?ContentTypeID=1</link><pubDate>Tue, 25 Apr 2023 18:08:08 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:03abce5f-c310-4456-9056-85fa1dd80869</guid><dc:creator>sanchitg0002</dc:creator><description>&lt;p&gt;You can use&amp;nbsp;readexcelsheetpaging() function available in&amp;nbsp;&lt;a href="/b/appmarket/posts/excel-tools"&gt;Excel Tools&lt;/a&gt;&amp;nbsp;plugin which return a datasubset that can be directly plugged to the data parameter of gridField().&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!data: readexcelsheetpaging(
    excelDocument: cons!PA_TEST_DOCUMENT,
    sheetNumber: 1,
    pagingInfo: a!pagingInfo(1, 100)
  ).data,
  local!labels: index(local!data, 1, &amp;quot;values&amp;quot;, null),
  {
    a!gridField(
      label: &amp;quot;Read-only Grid&amp;quot;,
      labelPosition: &amp;quot;ABOVE&amp;quot;,
      data: todatasubset(
        arrayToPage: remove(local!data, 1),
        pagingConfiguration: a!pagingInfo(1, 100)
      ),
      columns: a!forEach(
        local!labels,
        a!gridColumn(
          label: fv!item,
          value: fv!row.values[fv!index]
        )
      ),
      validations: {},
      pagingSaveInto: fv!pagingInfo
    )
  }
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamic CDT</title><link>https://community.appian.com/thread/111754?ContentTypeID=1</link><pubDate>Tue, 25 Apr 2023 17:58:24 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:2d725bb6-177c-4309-bd47-365fc37063f5</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;You&amp;#39;d probably need to read just the first (header) row and use those as your data keys.&amp;nbsp; It can be a bit tricky but in the past I&amp;#39;ve done it by manually transforming the result into a JSON string, then casting that back from JSON to dictionary.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamic CDT</title><link>https://community.appian.com/thread/111753?ContentTypeID=1</link><pubDate>Tue, 25 Apr 2023 17:57:18 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:25879e72-780c-4d76-9789-4a17f969d355</guid><dc:creator>Shikha</dc:creator><description>&lt;p&gt;Hi , Can you share the output of local!exceldata variable above?&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamic CDT</title><link>https://community.appian.com/thread/111752?ContentTypeID=1</link><pubDate>Tue, 25 Apr 2023 17:49:35 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:364a05a8-3328-4f29-ac78-14d32837783a</guid><dc:creator>sivasuryap0002</dc:creator><description>&lt;p&gt;Here The data will be minimal only and map and dictionary both are not possible as the field names are dynamic and logic based ie.,headers of the Excel and the excel cannot be static.&lt;br /&gt;Ex:&amp;nbsp;&amp;nbsp;a!map(local!exceldata.result[1].values[1]):&amp;quot;value&amp;quot;)&lt;br /&gt;Error :&amp;nbsp;&lt;span&gt;Expression evaluation error at function a!map [line 48]: Total keys and values must be equal. Received 0 keys and 1 values&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamic CDT</title><link>https://community.appian.com/thread/111750?ContentTypeID=1</link><pubDate>Tue, 25 Apr 2023 17:36:15 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:9742a99c-2a05-4d2f-afc3-7faa8c658dce</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;While I do not recommend to load a unknown volume of data into memory, is there a reason a map does not make it? Alternatively a dictionary. Did you try any&amp;nbsp;of these two?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>