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.

Note: To improve the readability of a Map, select the collapse () or expand () icons on the Block to display or hide all of the Blocks included within the selected Block.

Once a Control Block has been executed and the process has moved outside that Block, subsequent Blocks cannot read results from Blocks executed 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 Scribe® Online skips the entire For Each Child Block along with any Blocks within the For Each Child loop, for a record if:

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 executed.

Disable the If an error occurs, fail the record option 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

  1. 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.

  2. Drag and drop the For Each Child Block to the Map workspace.
  3. Select the Block.
  4. Select the General link from the Properties panel.
  5. Optionally, change the label and add a description for this Block.
  6. 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 Map, only one option is available in the Relationship drop-down.

  7. Select OK to close the Properties dialog.

When this Map is executed and TIBCO Scribe® Online finds a source record with associated children:

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 Map Errors And Warnings.

Once you have corrected the errors, select the Validate button to update the Errors and Warnings tab.

Related Topics

Control Blocks

Loop Block

Loop Exit Block