<?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/"><channel><title>KB-1121 Changing the batch size of a!queryEntity also changes the total count</title><link>https://community.appian.com/support/w/kb/343/kb-1121-changing-the-batch-size-of-a-queryentity-also-changes-the-total-count</link><description /><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>KB-1121 Changing the batch size of a!queryEntity also changes the total count</title><link>https://community.appian.com/support/w/kb/343/kb-1121-changing-the-batch-size-of-a-queryentity-also-changes-the-total-count</link><pubDate>Thu, 09 Aug 2018 02:12:51 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:acd1790d-1ce1-4615-b7ae-deb3139c9b67</guid><dc:creator>Parmida Borhani</dc:creator><comments>https://community.appian.com/support/w/kb/343/kb-1121-changing-the-batch-size-of-a-queryentity-also-changes-the-total-count#comments</comments><description>Current Revision posted to Appian Knowledge Base by Parmida Borhani on 8/9/2018 2:12:51 AM&lt;br /&gt;
&lt;div class="row content_container"&gt;
&lt;h2 id="symptoms"&gt;Symptoms&lt;/h2&gt;
&lt;p&gt;When using &lt;code&gt;a!queryEntity()&lt;/code&gt; within an expression, there is a discrepancy between the total count when using an infinite batch size (-1) versus a non-infinite batch size.&lt;/p&gt;
&lt;p&gt;For example, here is an &lt;code&gt;a!pagingInfo&lt;/code&gt; with an infinite batch size:&lt;/p&gt;
&lt;pre&gt;local!pagingInfo: 
  if( isnull(ri!pagingInfo),
    a!pagingInfo( startIndex: 1 , batchSize: -1),
    ri!pagingInfo
  )
&lt;/pre&gt;
&lt;p&gt;The above returns a totalCount of 3:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[startIndex=1, batchSize=-1, sort=[field=name, ascending=true], totalCount=3, data=[id:1, name:Bob]; [id:2, name:Jane]; [id:2, name:Joe],  identifiers=1,2,2]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Change the batch size to 3:&lt;/p&gt;
&lt;pre&gt;local!pagingInfo: 
  if( isnull(ri!pagingInfo),
    a!pagingInfo( startIndex: 1 , batchSize: 3),
    ri!pagingInfo
  )
&lt;/pre&gt;
&lt;p&gt;The above returns a totalCount of 2:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[startIndex=1, batchSize=-1, sort=[field=name, ascending=true], totalCount=2, data=[id:1, name:Bob]; [id:2, name:Jane]; [id:2, name:Joe],  identifiers=1,2,2]
&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id="cause"&gt;Cause&lt;/h2&gt;
&lt;p&gt;The column used as the identifier has duplicate values. This is generally bad database design and is not recommended by Appian Technical Support.&lt;/p&gt;
&lt;p&gt;In the example above, identifiers contains [1,2,2]. When batch size of -1 is used, totalCount is 3 since it returns the total number of values. When a batch size of anything besides -1 is used, it returns the unique number of values, and since 2 appears twice, the totalCount is 2.&lt;/p&gt;
&lt;h2 id="action"&gt;Action&lt;/h2&gt;
&lt;p&gt;To find the column with duplicates:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Run the expression in Interface Designer.&lt;/li&gt;
&lt;li&gt;Look at the identifiers parameter of the expression output. There will be duplicate values within this parameter.&lt;/li&gt;
&lt;li&gt;To determine which column is associated to the values being used by the identifiers, copy and find one of the values from the identifiers parameter in the data parameter of the expression output.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Enforce uniqueness on the column that is being used by the identifiers parameter. Consult with your DBA about adding a primary key to that column if one doesn&amp;#39;t already exist.&lt;/p&gt;
&lt;h2 id="affected-versions"&gt;Affected Versions&lt;/h2&gt;
&lt;p&gt;This article applies to all versions of Appian.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Last Reviewed:&amp;nbsp;February 2017&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: interfaces, database, application design, infrastructure&lt;/div&gt;
</description></item><item><title>KB-1121 Changing the batch size of a!queryEntity also changes the total count</title><link>https://community.appian.com/support/w/kb/343/kb-1121-changing-the-batch-size-of-a-queryentity-also-changes-the-total-count/revision/1</link><pubDate>Fri, 24 Feb 2017 13:45:10 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:acd1790d-1ce1-4615-b7ae-deb3139c9b67</guid><dc:creator>Nick Vigilante</dc:creator><comments>https://community.appian.com/support/w/kb/343/kb-1121-changing-the-batch-size-of-a-queryentity-also-changes-the-total-count#comments</comments><description>Revision 1 posted to Appian Knowledge Base by Nick Vigilante on 2/24/2017 1:45:10 PM&lt;br /&gt;
&lt;div class="row content_container"&gt;
&lt;h2 id="symptoms"&gt;Symptoms&lt;/h2&gt;
&lt;p&gt;When using &lt;code&gt;a!queryEntity()&lt;/code&gt; within an expression, there is a discrepancy between the total count when using an infinite batch size (-1) versus a non-infinite batch size.&lt;/p&gt;
&lt;p&gt;For example, here is an &lt;code&gt;a!pagingInfo&lt;/code&gt; with an infinite batch size:&lt;/p&gt;
&lt;pre&gt;local!pagingInfo: 
  if( isnull(ri!pagingInfo),
    a!pagingInfo( startIndex: 1 , batchSize: -1),
    ri!pagingInfo
  )
&lt;/pre&gt;
&lt;p&gt;The above returns a totalCount of 3:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[startIndex=1, batchSize=-1, sort=[field=name, ascending=true], totalCount=3, data=[id:1, name:Bob]; [id:2, name:Jane]; [id:2, name:Joe],  identifiers=1,2,2]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Change the batch size to 3:&lt;/p&gt;
&lt;pre&gt;local!pagingInfo: 
  if( isnull(ri!pagingInfo),
    a!pagingInfo( startIndex: 1 , batchSize: 3),
    ri!pagingInfo
  )
&lt;/pre&gt;
&lt;p&gt;The above returns a totalCount of 2:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[startIndex=1, batchSize=-1, sort=[field=name, ascending=true], totalCount=2, data=[id:1, name:Bob]; [id:2, name:Jane]; [id:2, name:Joe],  identifiers=1,2,2]
&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id="cause"&gt;Cause&lt;/h2&gt;
&lt;p&gt;The column used as the identifier has duplicate values. This is generally bad database design and is not recommended by Appian Technical Support.&lt;/p&gt;
&lt;p&gt;In the example above, identifiers contains [1,2,2]. When batch size of -1 is used, totalCount is 3 since it returns the total number of values. When a batch size of anything besides -1 is used, it returns the unique number of values, and since 2 appears twice, the totalCount is 2.&lt;/p&gt;
&lt;h2 id="action"&gt;Action&lt;/h2&gt;
&lt;p&gt;To find the column with duplicates:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Run the expression in Interface Designer.&lt;/li&gt;
&lt;li&gt;Look at the identifiers parameter of the expression output. There will be duplicate values within this parameter.&lt;/li&gt;
&lt;li&gt;To determine which column is associated to the values being used by the identifiers, copy and find one of the values from the identifiers parameter in the data parameter of the expression output.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Enforce uniqueness on the column that is being used by the identifiers parameter. Consult with your DBA about adding a primary key to that column if one doesn&amp;#39;t already exist.&lt;/p&gt;
&lt;h2 id="affected-versions"&gt;Affected Versions&lt;/h2&gt;
&lt;p&gt;This article applies to all versions of Appian.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Last Reviewed:&amp;nbsp;February 2017&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: interfaces, database&lt;/div&gt;
</description></item></channel></rss>