<?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>Recursively get db entries</title><link>https://community.appian.com/discussions/f/data/25197/recursively-get-db-entries</link><description>Hi Everyone, 
 I&amp;#39;ve got a CDT that has an Id as a Primary Key and then a Numeric field that is a reference to a previous same-cdt entry id. 
 Starting from an ID I need to back-track all the way to the first &amp;quot;father&amp;quot; entry. All should be done using Expression</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Recursively get db entries</title><link>https://community.appian.com/thread/98238?ContentTypeID=1</link><pubDate>Fri, 22 Jul 2022 13:57:17 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:90130196-91de-404b-9797-56676ead96f5</guid><dc:creator>fredaf</dc:creator><description>&lt;p&gt;Hi Luca,&lt;br /&gt;&lt;br /&gt;I wouldn&amp;#39;t recommend using this type of recursion in Appian as it&amp;#39;s not a best practice. But, I&amp;nbsp;tried it using a recursive call to the main expression rule to backtrack through the list mainly using the displayvalue function. Here&amp;#39;s the code snippet and it returns a list of strings that u can edit as per your requirement, for this case i passed the ri value as 4 -&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;i class="SelectableTreeNode---icon SelectableTreeNode---openCloseLink"&gt;&lt;/i&gt;&lt;span&gt;&lt;span class="CollapsibleOutputNode---print_value"&gt;&amp;quot;FID value is 3 FID value is 2 FID value is 1 Depth reached &amp;quot;&lt;/span&gt;&lt;span class="CollapsibleOutputNode---print_element_type"&gt;(Text)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!cdtset: {
    &amp;#39;type!{urn:com:appian:types}test_cdt_1&amp;#39;(&amp;#39;ID&amp;#39;: 1, &amp;#39;fID&amp;#39;: null),
    &amp;#39;type!{urn:com:appian:types}test_cdt_1&amp;#39;(&amp;#39;ID&amp;#39;: 2, &amp;#39;fID&amp;#39;: 1),
    &amp;#39;type!{urn:com:appian:types}test_cdt_1&amp;#39;(&amp;#39;ID&amp;#39;: 3, &amp;#39;fID&amp;#39;: 2),
    &amp;#39;type!{urn:com:appian:types}test_cdt_1&amp;#39;(&amp;#39;ID&amp;#39;: 4, &amp;#39;fID&amp;#39;: 3)
  },
  local!newvalue: displayvalue(
    ri!value,
    local!cdtset.&amp;#39;ID&amp;#39;,
    local!cdtset.&amp;#39;fID&amp;#39;,
    0
  ),
  if(
    or(
      a!isNullOrEmpty(local!newvalue),
      local!newvalue = 0
    ),
    { &amp;quot;Depth reached &amp;quot; &amp;amp; local!newvalue },
    {
      &amp;quot;FID value is &amp;quot; &amp;amp; local!newvalue &amp;amp; char(10) &amp;amp; rule!test_recursiveEr(local!newvalue)
    }
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>