Hi,
I’m implementing a BOM-driven movement posting and facing issues with CONTEXT("RowKey") during nested action execution.
Data Structure
BOM
• Key ID
BOMLI (child of BOM)
• Key ID
• BOM ID (Ref to BOM)
• Inventory ID
• BOM Line Item Type: Production/Consumption
• BOMLI Input Quantity
TRN
• Key ID
• BOM ID (Ref → BOM)
MOV (child of TRN)
• Key ID
• Transaction ID (Ref to TRN)
• Movement Type: Production/Consumption
• Inventory ID
• Input Quantity
Goal
When a user presses Post Consumptions on a TRN record, the app should:
-
Read BOMLI lines for the selected BOM
-
Filter rows where
[BOM Line Item Type] = "Consumption" -
Create MOV lines linked to the TRN
Action Structure
Action 1 – Post Consumptions
For a record of this table: BOMLI
Type: Data: add a new row to another table using values from this row
Target table: MOV
Set columns:
Transaction ID: CONTEXT("RowKey")
Movement Type: [BOM Line Item Type]
Inventory ID: [Inventory ID]
Note: The Input Quantity field in the MOV table already contains the quantity calculation logic in its Initial Value.
Action 2 – Post Consumptions (Ref)
For a record of this table: TRN
Type: Data: Execute an action on a set of rows
Referenced table: BOMLI
Referenced rows:
SELECT( BOMLI[Key ID], AND( [BOM ID] = [_THISROW].[BOM ID], [BOM Line Item Type] = "Consumption" ) )
Referenced action: Post Consumptions
Issue
CONTEXT("RowKey") appears to return the Key ID of the BOMLI, not the Key ID of the TRN, when the action runs. As a result, the MOV receives the wrong Transaction ID.
Debugging
When I hardcoded the Transaction ID, the MOV lines were created correctly and linked to the TRN. So it seems the issue is specifically how CONTEXT("RowKey") behaves inside nested actions.
Question
Is CONTEXT("RowKey") expected to return the current action’s Key ID (BOMLI in this case)?
If so, what is the recommended pattern to pass the Key ID of the TRN into the Post Consumptions action when executing nested actions like this?
Thanks in advance for any guidance!