For Each Child Block
Use the For Each Child Control block to process entities that have a child relationship with a related parent entity. You can, for example, use a For Each Child block to process each Item or child associated with a Sales Order or parent. You can also process all Contact records associated with an Account.
Once a Control block runs and the process moves outside that block, subsequent blocks cannot read results from blocks run inside the Control block. For example, results obtained by blocks within a For Each Child block, cannot be read by blocks outside the For Each Child block.
TIBCO Cloud™ Integration - Connect skips the entire For Each Child block along with any blocks within the For Each Child loop, for a record if:
- A parent record has no related child records.
- The child entity is not mapped in the target.
Nesting Blocks
Depending on your requirements, you can nest For Each Child blocks as long as each block references a different parent-child relationship.
In the case of hierarchical data, you can nest For Each Child blocks to reach the next level down in the hierarchy. For example, assume you have an entity named Country that is the parent. Within that entity, you have States that contain Cities and Cities that contain Businesses. Your first For Each Child block would reference States, inside that For Each Child block you would nest a second For Each Child that references Cities, and then a third that references Businesses. See Hierarchical Data.
Failed Records
If a Child record fails, the remaining Child records are skipped, and the next source record is processed. There are two options for working around this issue.
Enable Batch Processing on the blocks within the For Each Child block. Child records with errors in a batch do not stop remaining Child records from being processed. However, data fields and Result Fields from blocks with Batch Processing enabled cannot be used in subsequent blocks, because the data may not have been stored when those blocks ran.
Disable the option, If an error occurs, fail the record, on the Error Handing tab in the target operation block. Use an If/Else Block to evaluate the Result Fields from the target operation block and control how Child records are processed.
Block Properties - General Tab
From the General tab, you can change the Block Label, add a description, and select the Relationship to use for this Block.
Use a For Each Child Block
- Before you can use a For Each Child block, you need to declare one or more Parent/Child Relationships in the Query Block, the CreateWith Block, the UpdateWith Block, or the UpsertWith Block. See Block Properties Include Tab — Relational Data and Block Properties Include Tab — Hierarchical Entities.Note: Only child entities, where the Relationship Type is Child or Zero or more in the Query Block, display in a For Each Child Block.
- Drag and drop the For Each Child block to the Flow workspace.
- Select the block.
- Select the General link from the Properties panel.
- Optionally, change the label and add a description for this block.
- In the Relationship drop-down box, select the Relationship you want to use for this block. Note: If you included a single parent-child relationship in the Query Block for this flow, only one option is available in the Relationship drop-down.
- Select OK to close the Properties dialog.
When this flow runs and TIBCO Cloud™ Integration - Connect finds a source record with associated children:
- TIBCO Cloud™ Integration - Connect processes each child record within the For Each Child loop.
- When all of the child records for that source record are processed, TIBCO Cloud™ Integration - Connect runs the next block outside of the For Each Child block.
Block Properties - Errors and Warnings Tab
If there are any errors or warnings for this block, the Errors and Warnings tab displays the number of errors or warnings in the tab name. See Block And Flow Errors And Warnings.
Once you have corrected the errors, select the Validate button to update the Errors and Warnings tab.