When using a!queryEntity() within an expression, there is a discrepancy between the total count when using an infinite batch size (-1) versus a non-infinite batch size.
a!queryEntity()
For example, here is an a!pagingInfo with an infinite batch size:
a!pagingInfo
local!pagingInfo: if( isnull(ri!pagingInfo), a!pagingInfo( startIndex: 1 , batchSize: -1), ri!pagingInfo )
The above returns a totalCount of 3:
[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]
Change the batch size to 3:
local!pagingInfo: if( isnull(ri!pagingInfo), a!pagingInfo( startIndex: 1 , batchSize: 3), ri!pagingInfo )
The above returns a totalCount of 2:
[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]
The column used as the identifier has duplicate values. This is generally bad database design and is not recommended by Appian Technical Support.
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.
To find the column with duplicates:
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't already exist.
This article applies to all versions of Appian.
Last Reviewed: February 2017