<?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>Query Key Values</title><link>https://community.appian.com/discussions/f/data/12764/query-key-values</link><description>I currently have a data table that that uses key/values similar to this: 
 
 param_table{ 
 id, 
 taskId, 
 key, 
 value 
 } 
 row1 { 
 1, 
 123, 
 &amp;quot;string&amp;quot;, 
 1 
 } 
 
 row2{ 
 2, 
 123, 
 &amp;quot;string2&amp;quot;, 
 2 
 } 
 
 I need to return taskId based on key{string</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Query Key Values</title><link>https://community.appian.com/thread/57135?ContentTypeID=1</link><pubDate>Tue, 26 Jun 2018 06:33:55 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:3633a648-5ad6-454e-b08e-0e71df737967</guid><dc:creator>Abhay Giri</dc:creator><description>Hi,&lt;br /&gt;
&lt;br /&gt;
Use a!queryentity to get taskid, &lt;br /&gt;
&lt;br /&gt;
a!queryEntity(&lt;br /&gt;
  entity: entity constant,&lt;br /&gt;
  query: a!query(&lt;br /&gt;
    pagingInfo: a!pagingInfo(&lt;br /&gt;
      startIndex: 1,&lt;br /&gt;
      batchSize: 1&lt;br /&gt;
    ),&lt;br /&gt;
    filter: a!queryFilter(&lt;br /&gt;
      field: &amp;quot;key&amp;quot;,&lt;br /&gt;
      operator: =&amp;quot;=&amp;quot;,&lt;br /&gt;
      value: ri!keyName&lt;br /&gt;
    )&lt;br /&gt;
  )&lt;br /&gt;
).data.value&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
or you can use selection as well:&lt;br /&gt;
&lt;br /&gt;
a!queryEntity(&lt;br /&gt;
  entity: entity constant,&lt;br /&gt;
  query: a!query(&lt;br /&gt;
    pagingInfo: a!pagingInfo(&lt;br /&gt;
      startIndex: 1,&lt;br /&gt;
      batchSize: 1&lt;br /&gt;
    ),&lt;br /&gt;
    selection: a!querySelection(&lt;br /&gt;
      columns: a!queryColumn(&amp;quot;Value&amp;quot;)&lt;br /&gt;
    )&lt;br /&gt;
    &lt;br /&gt;
    filter: a!queryFilter(&lt;br /&gt;
      field: &amp;quot;key&amp;quot;,&lt;br /&gt;
      operator: =&amp;quot;=&amp;quot;,&lt;br /&gt;
      value: ri!keyName&lt;br /&gt;
    )&lt;br /&gt;
  )&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
Regards&lt;br /&gt;
Abhay&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Query Key Values</title><link>https://community.appian.com/thread/57133?ContentTypeID=1</link><pubDate>Tue, 26 Jun 2018 06:07:36 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:3e984bec-5b7d-4586-953a-23326f28cdbd</guid><dc:creator>santoshd378</dc:creator><description>Hi Jawara,&lt;br /&gt;
&lt;br /&gt;
By using the query entity you can achieve this, use the following code:&lt;br /&gt;
&lt;br /&gt;
a!queryEntity(&lt;br /&gt;
  entity: Your entity constant,&lt;br /&gt;
  query: a!query(&lt;br /&gt;
    selection: a!querySelection(&lt;br /&gt;
      columns: {&lt;br /&gt;
        a!queryColumn(&lt;br /&gt;
          field: &amp;quot;taskId&amp;quot;&lt;br /&gt;
        )&lt;br /&gt;
      }&lt;br /&gt;
    ),&lt;br /&gt;
    filter: a!queryFilter(&lt;br /&gt;
      field: &amp;quot;Key&amp;quot;,&lt;br /&gt;
      operator: &amp;quot;=&amp;quot;,&lt;br /&gt;
      value: ri!Key /*create ri variable to pass the key dynamically while calling your expression rule*/&lt;br /&gt;
    )&lt;br /&gt;
  )&lt;br /&gt;
)&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Query Key Values</title><link>https://community.appian.com/thread/57132?ContentTypeID=1</link><pubDate>Tue, 26 Jun 2018 05:53:01 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:dc0d9db3-363d-4b98-bb33-c16d17e58812</guid><dc:creator>Shiva Valusa</dc:creator><description>&lt;p&gt;Hi Jawara J,&lt;br /&gt; &lt;br /&gt; Please go through Query Recipes page as well once.&lt;br /&gt; &lt;br /&gt; &lt;a href="https://docs.appian.com/suite/help/18.2/Query_Recipes.html"&gt;docs.appian.com/.../Query_Recipes.html&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Query Key Values</title><link>https://community.appian.com/thread/57125?ContentTypeID=1</link><pubDate>Tue, 26 Jun 2018 05:17:50 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e63508cc-ec04-4e2b-bf3a-469f2603f18e</guid><dc:creator>Shubham Aware</dc:creator><description>Hi &lt;a href="/members/jawaraj0001"&gt;Jawara J&lt;/a&gt; ,&lt;br /&gt;
&lt;br /&gt;
You can use a!queryEntity if you have data is in database By applying queryFilter you can retrieve data based on key.&lt;br /&gt;
You can use index, filter, wherecontains function to filter out data based on particular key.&lt;br /&gt;
&lt;br /&gt;
Simple solution to this is you can create expression rule which contains key as well as value like dictionary and simple calling that rule you can approach this.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Query Key Values</title><link>https://community.appian.com/thread/57114?ContentTypeID=1</link><pubDate>Mon, 25 Jun 2018 20:41:02 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b04f21c5-04fe-4c16-bafe-0d8b7e981784</guid><dc:creator>Umesh Patel</dc:creator><description>Hi,&lt;br /&gt;
Considering unique key-value pair, you can use query entity to fetch particular task id based on parameters key &amp;amp; value if its in DB table.&lt;br /&gt;
If everything is in memory, you can use wherecontains and index.&lt;br /&gt;
Thanks.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Query Key Values</title><link>https://community.appian.com/thread/57113?ContentTypeID=1</link><pubDate>Mon, 25 Jun 2018 20:34:32 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:175c9ee4-2cd9-4cf6-afd0-00491e5a6544</guid><dc:creator>jeromew</dc:creator><description>&lt;p&gt;Something like this might work if you have an ordered key and value list:&lt;br /&gt; &lt;br /&gt;a!queryEntity(&lt;br /&gt;&amp;nbsp; entity: &amp;lt;yourentity&amp;gt;,&lt;br /&gt;&amp;nbsp; query: a!query(&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; selection: &amp;quot;taskId&amp;quot;,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; logicalExpression: a!queryLogicalExpression(&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; logicalExpressions: a!forEach(&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; items: &amp;lt;yourkeylist&amp;gt;,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; expression: a!queryLogicalExpression(&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; operator: &amp;quot;=&amp;quot;,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; filters: a!queryFilter(&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; field: &amp;quot;key&amp;quot;,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; operator: &amp;quot;=&amp;quot;,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value: &amp;lt;yourvaluelist&amp;gt;[fv!index]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ),&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pagingInfo: a!pagingInfo(startIndex: 1, batchSize: -1, sort: {})&lt;br /&gt;&amp;nbsp; )&lt;br /&gt;)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Let me tell you why this is a good way to implement this solution.&lt;/p&gt;
&lt;p&gt;1. You&amp;#39;re limiting the data being retrieved with the selection: &amp;quot;taskId&amp;quot;. Loading less data is more efficient.&lt;/p&gt;
&lt;p&gt;2. You&amp;#39;re setting the filters up front which also limits the data being retrieved. This is a more efficient solution than loading the data in and trying to iterate it with wherecontains() or other functions.&lt;/p&gt;
&lt;p&gt;Always try and reduce the dataset up front so you retrieve only the needed data.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>