--- title: "Calculate aggregate number of packages (Shipment)" slug: "shp-calculate-aggregate-number-of-packages-actor" updated: 2026-04-02T08:02:49Z published: 2026-04-02T08:02:49Z canonical: "docs.lobstersoftware.com/shp-calculate-aggregate-number-of-packages-actor" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.lobstersoftware.com/llms.txt > Use this file to discover all available pages before exploring further. # Calculate aggregate number of packages (Shipment) *See also:* [Calculate aggregate number of packages](/v1/docs/en/cmn-calculate-aggregate-number-of-packages-actor)*,* [Calculate aggregate number of packages (Order)](/v1/docs/en/ord-calculate-aggregate-number-of-packages-actor) > [!NOTE] > Event action – Abstract > > **Purpose:** Populates the fields for 'Aggregate number of packages' across line item levels of all or selected line item types in a shipment and optionally (additionally) summarizes the 'Number of packages' of the direct line items as on the header level. > > > [!TIP] > > Tooltip > > > > - **Usage:** The event action must be executed with a shipment as the *reference object*. The calculation optionally takes into account *selected* or *all* **Line item types**. Depending on the **Calculate summary** option, the 'Number of packages' in the header level is also updated. > > - **Parameter:** > > - The *optional* multiple selection for **Line item types** defines line item types for which the 'Aggregate number of packages' should be calculated. By default (without a selection), the 'Aggregate number of packages' is updated in line items of all types. > > - The **Calculate summary** option defines whether the sum over the 'Number of packages' of the direct line items of all relevant **Line item types** should be assigned to the 'Number of packages' field in the header of the shipment. > > - **Output:** > > - Updates the 'Aggregate number of packages' field of all relevant **Line item types**. > > - *Optional*: Updates the 'Number of packages' in the header level as a summary over the 'Number of packages' in direct line items of the relevant **Line item types**. ![images/download/attachments/177912585/image-2024-9-19_10-50-42-version-1-modificationdate-1726735841531-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/image-2024-9-19_10-50-42-version-1-modificationdate-1726735841531-api-v2.png) The event action [Calculate aggregate number of packages (Shipment)](/v1/docs/en/shp-calculate-aggregate-number-of-packages-actor) executes the following steps for all or selected **Line** **item** **types** (see [Line item type](/v1/docs/en/base-line-item-type)) in a *reference object* of the 'Shipment' type (see [Shipments](/v1/docs/en/shp-shipment)): 1. Within the line item hierarchy for each relevant [Line item type](/v1/docs/en/base-line-item-type), the field 'Number of packages' (`numberOfPackages`) is assigned the value 1 for each line item if it is empty or filled with 0. 2. Within the line item hierarchy for each relevant [Line item type](/v1/docs/en/base-line-item-type), the field 'AggregateNumberOfPackages' (`aggregateNumberOfPackages`) is filled for each line item according to the procedure described in the section 'Calculation logic'. 3. If the option **Calculate summary** is selected (default), then the total is additionally calculated via the field 'Number of packages' (`numberOfPackages`) in all direct line items for all relevant **Line item types**. 4. This total number is assigned to the field 'Number of packages' (`numberOfPackages`) of the *reference object*. **NOTE:** Details on the calculation logic and an informative runtime example can be found on the page for the entity type [Common business object](/v1/docs/en/orchestration-common-bto): - [Calculate aggregate number of packages](/v1/docs/en/cmn-calculate-aggregate-number-of-packages-actor) ## Configuration ![images/download/attachments/177912585/image-2024-9-19_10-50-6-version-1-modificationdate-1726735805617-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/image-2024-9-19_10-50-6-version-1-modificationdate-1726735805617-api-v2.png) The event action [Calculate aggregate number of packages (Shipment)](/v1/docs/en/shp-calculate-aggregate-number-of-packages-actor) expects a shipment (see [Shipments](/v1/docs/en/shp-shipment)) as the *reference object*. In the context of another object type, the event action has no effect without an error occurring at runtime. The **Calculate summary** option (set by default) controls whether the 'Number of packages' field in the *reference* *object* header data should be updated based on the information for [Direct line items](/v1/docs/en/base-get-line-items-resolver) of the relevant **Line item types**. Multiple selection for **Line item types** can be used to define a positive list for *relevant* **Line item types** (see [Line item type](/v1/docs/en/base-line-item-type)). - If no **Line item types** are selected, all line items in the *reference* *object* are evaluated regardless of the [Line item type](/v1/docs/en/base-line-item-type).