Group by in an entity find?

I’m trying to do a more custom order find for FindOrders in the simplescreens component. However I do not understand why the entity find defined in the screen does the group by, or at least only shows one record per order part. Like this:

And this is the entity find:

        <entity-find entity-name="mantle.order.OrderPartFindView" list="orderList" use-clone="true">
            <search-form-inputs default-order-by="-entryDate,orderId,orderPartSeqId"
                <!-- NOTE: OrderOpen no longer included by default to exclude shopping cart orders (salesChannelEnumId == 'ScWeb') -->
                <default-parameters partStatusId="OrderProposed,OrderRequested,OrderPlaced,OrderApproved,OrderHold" partStatusId_op="in"
                        entryDate_poffset="-3" entryDate_period="30d"/></search-form-inputs>
            <date-filter from-field-name="customerClassFromDate" thru-field-name="customerClassThruDate" ignore="!customerClassificationId"/>
            <econdition field-name="vendorRoleTypeId" value="OrgInternal" ignore="!'sales'.equalsIgnoreCase(orderType)"/>
            <econdition field-name="customerRoleTypeId" value="OrgInternal" ignore="!'purchase'.equalsIgnoreCase(orderType)"/>
            <econdition field-name="customerClassificationId" ignore-if-empty="true"/>
            <econdition field-name="itemTypeEnumId" operator="in" ignore-if-empty="true" or-null="true"/>
            <econdition field-name="productId" operator="in" from="findProductId" ignore-if-empty="true"/>
            <econdition field-name="quantity" operator="greater-equals" from="findQuantity_from" ignore-if-empty="true"/>
            <econdition field-name="quantity" operator="less-equals" from="findQuantity_thru" ignore-if-empty="true"/>
            <econdition field-name="recurCronExpression" operator="is-not-null" ignore="onlyRecurring != 'true'"/>
                <econdition field-name="issuedQuantity" operator="greater" from="0.0" ignore="onlyPartlyShipped != 'true'"/>
                <econdition field-name="quantityNotAvailable" operator="equals" from="0.0" ignore="inventoryAvailable != 'all'"/>
                <econdition field-name="quantityNotAvailable" operator="greater" from="0.0" ignore="inventoryAvailable != 'partial' &amp;&amp; inventoryAvailable != 'notall'"/>
                <econdition field-name="quantityNotAvailable" operator="less" to-field-name="quantity" ignore="inventoryAvailable != 'partial'"/>
                <econdition field-name="quantityNotAvailable" operator="equals" to-field-name="quantity" ignore="inventoryAvailable != 'none'"/>
            <!-- NOTE: need to select issuedQuantity,quantityNotAvailable if having conditions are used (EntityFindBuilder doesn't yet add these to sub-select automatically) -->
            <select-field field-name="currencyUomId,orderPartSeqId${onlyPartlyShipped=='true' ? ',issuedQuantity' : ''}${inventoryAvailable in ['all','partial','none','notall'] ? ',quantityNotAvailable' : ''}${inventoryAvailable in ['partial','none'] ? ',quantity' : ''}"/>

For reference, this is the records I get when trying to do an entity find of the same view entity (OrderPartFindView) in a service outside the screen:

1 Like

Can you share the code in your service? My understanding is that what drives grouping when doing an entity find on a view entity is the select fields. The simplest way to figure out what is giving you multiple records would probably be to start with only one field in the select-field tag, like orderPartSeqId. See if that gives you one record, then add another field and test.

That’s correct, the group by fields are determined automatically by the fields selected… and especially with larger view entities you pretty much always want to limit the fields selected.

The difference you are seeing with entity-find under form-list vs entity-find in XML Actions is that under a form-list the fields currently displayed (based on form definitions, and if applicable the user-configured displayed columns) are selected automatically, in addition to any fields to select specified in the entity-find.

This is how flexible reports are built with field/column mapping options so the user can group totals by different fields. For example on the Invoice Items report you can get summary totals by any combination of To Party (Customer), Product, Item Type, etc. For example, see totals of Sales Tax (via Item Type) by Product by showing those two but not To Party, Invoice ID (no result per invoice), etc.

There is more info in the docs about view-entities, fields selected, and things like the view-entity automatic member-entity trimming, which is another important part of the design to support these sorts of flexible queries (without having to use a DynamicViewEntity to manually add only the member/joined entities/tables you need/want).