Skip to main content

system.mes.trackandtrace.getLotTraceTable

Description

Retrieves detailed data for the track and trace table for the given inventory lot record IDs. This function returns information about the connections between inventory lots, including source and target lots, locations, quantities, and timestamps.

While getLotTraceGraph provides a visual representation of material flows, getLotTraceTable provides more detailed tabular data about specific inventory lot records.

Permissions

This scripting function has no client permission restrictions.

Syntax

system.mes.trackandtrace.getLotTraceTable(inventoryLotRecordIds)

Parameters

ParameterTypeDescriptionRequired
inventoryLotRecordIdsList<String> (ULID)List of inventory lot record IDs to retrieveYes

Returns

A list of trace table row objects with the following properties:

TraceTableRow

PropertyTypeDescription
idString (ULID)ID of the inventory lot record
lotRecordTypeStringInventory lot record type (e.g. "Consume", "Produce", "Split", "Merge")
sourceInventoryLotIdString (ULID)ID of the source inventory lot
sourceInventoryLotNameStringName of the source inventory lot
targetInventoryLotIdString (ULID)ID of the target inventory lot
targetInventoryLotNameStringName of the target inventory lot
sourceLocationIdString (ULID)ID of the source location
sourceLocationPathStringPath of the source location
destinationLocationIdString (ULID)ID of the destination location
destinationLocationPathStringPath of the destination location
quantityDoubleQuantity of the record
unitOfMeasureIdString (ULID)ID of the unit of measure for the quantity
unitOfMeasureNameStringName of the unit of measure
unitOfMeasureSymbolStringSymbol of the unit of measure (e.g., "kg", "L")
startDateDateRecord start date
endDateDateRecord end date
durationInMillisLongDuration of the record in milliseconds (end date - start date)
sourceMaterialIdString (ULID)ID of the material associated with the source lot
sourceMaterialNameStringName of the material associated with the source lot
targetMaterialIdString (ULID)ID of the material associated with the target lot
targetMaterialNameStringName of the material associated with the target lot

Code Example

# First get the trace graph to obtain the edge IDs
inventoryLotId = "01JZJZ1FSE-WAW6VBVG-4506XP0C"
traceGraph = system.mes.trackandtrace.getLotTraceGraph(inventoryLotId, "OUTPUT")

# Extract the edge IDs from the trace graph
edgeIds = [edge["id"] for edge in traceGraph["edges"]]

# Use the edge IDs to get detailed trace table information
traceTableRows = system.mes.trackandtrace.getLotTraceTable(edgeIds)

# Print the table data
for row in traceTableRows:
print(f"Record Type: {row['lotRecordType']}")
print(f"Source Lot: {row['sourceInventoryLotName']} (Material: {row['sourceMaterialName']})")
print(f"Target Lot: {row['targetInventoryLotName']} (Material: {row['targetMaterialName']})")
print(f"Quantity: {row['quantity']} {row['unitOfMeasureSymbol']}")
print(f"From: {row['sourceLocationPath']} → To: {row['destinationLocationPath']}")
print(f"Start: {row['startDate']}, End: {row['endDate']}, Duration: {row['durationInMillis']}ms")
print("---")

Example Output

Record Type: Produce
Source Lot: Lot-01JZJZ (Material: apple)
Target Lot: Lot-01JRGM (Material: cherry)
Quantity: 100.0 kg
From: /Facility/Line1 → To: /Facility/Warehouse
Start: 2023-06-15T14:30:00Z, End: 2023-06-15T14:45:00Z, Duration: 900000ms
---