This article outlines the implementation of a Custom Logic flow that generates an entity subset for task execution. One or more Broadway flows can be designed to define the logic, which ultimately produces an output list of entity IDs. During task execution, this list is returned and used by the TDM process to extract or load data.
TDM supports two execution modes for running Custom Logic flows: Direct Call and Indirect Call. These modes define how the list of entities is retrieved and processed by a task’s batch process.
Direct Call Mode — in this mode, the batch process triggers the Custom Logic flow at runtime, which immediately returns the list of entities. The entities are streamed directly from the flow, without any intermediate storage or preloading.
The Custom Logic flow must contain only one DbCommand with a single SELECT query that retrieves the entity list. Additionally, the associated Business Entity must include only one Root LU. For Business Entities with multiple Root LUs the Indirect Call mode should be used instead.
The task processes entity IDs in data chunks as they are retrieved, without waiting for the full list to load. This streaming approach significantly improves performance when working with large datasets.
Indirect Call Mode — in this mode, the Custom Logic flow runs before the batch process begins, generating a list of entity IDs and storing them in a temporary table within the TDM database. This table is created specifically for the task execution, following the naming convention entity_list_<task exe_id>
.
Unlike Direct Call, the entire entity list is written in advance, and the task retrieves entities by querying this table during execution. Once processing is complete, the table is automatically removed.
Indirect Call supports complex scenarios, such as Business Entities with multiple Root LUs that require a unified list of entities. It is also useful when the entity list needs to be reviewed, reused, or further processed before task execution.
The Custom Logic Broadway flow can be created in either the Shared Objects or a given LU.
The Custom Logic Broadway flow always includes two external input parameters, whose values are provided by the task execution process:
TDM supports the creation of additional external parameters in the flow, enabling the user to send the values of these parameters in the TDM task. For example, you can add an external parameter named customer_status to the flow. The flow then selects customers for the task based on this input parameter. This way, you can filter customers by their status and still use the same flow to select them.
Notes:
The input parameter name must not contain spaces or double quotes.
TDM V8.0 introduced integration of Broadway editors into the TDM portal when populating either data generation or Custom logic parameters in the task tabs. This integration enables users to select valid values from a list, set dates, and configure distributed parameters.
Click here for more information about TDM integration with Broadway editors and related implementation instructions.
Sending multiple values in one parameter — you can define a String input parameter to provide a list of values, which the Broadway flow can split into an array using a specified delimiter (e.g.,"CA,NY"). The delimiter is configured in the split Actor within the flow.
You can define a SELECT statement as an input argument. The SELECT statement can have binding parameters. The parameter values can be provided either through separate input parameters or directly within the SELECT statement. See the CustomLogicSql flow's examples below.
A Direct Call Custom Logic flow should have the following structure:
Init — calls the TDMSetSessionGlobals Actor to run the initial setting for the Custom Logic flow execution. The SESSION_GLOBALS input parameter must be defined as an external parameter named SESSION_GLOBALS.
DbCommand — defines the SELECT statement to select the task entities. The SELECT statement must return only the entity IDs.
customLogicDirectFlowUtil — filters out the reserved entities if needed, and formats the entity IDs for the task execution:
Stage 1:
Stages 2-4: Loop on the selected entities — set a Transaction within the loop to ensure a single commit for all iterations:
Stage 2: Set the selected entity ID — returned by the Actor of Stage 1 — to a String using the ToString Actor.
Stage 3: Call the CheckReserveAndLoadToEntityList TDM Broadway flow (imported from the TDM library):
Input — LU_NAME parameter. This is an external parameter, whose value is populated by the task execution process.
Output — recordLoaded. This is the entity number counter, which is loaded into the entity table.
This flow executes the following activities on each selected entity ID:
Stage 4: Call the CheckAndStopLoop TDM Actor (imported from the TDM library). Set the NUM_OF_ENTITIES to be an external input parameter, whose value is populated by the task execution process. This Actor checks the number of entities inserted to the entity table, and stops the loop if the custom flow reaches the task's number of entities.
Example:
The task needs to retrieve 5 entities. The SELECT statement selects 20 entities. The first 2 selected entities are reserved for another user. The 3rd, 4th, 5th, 6th, and 7th entities are available and are populated in the entity table; the entity loop then stops.
Examples of a Custom Logic flow are shown below:
Example 1 — get the Contract Status as an input parameter and build the SELECT statement accordingly:
Example 2 — get an input String of states, separated by a comma. Split the input String into an array and send it to the SQL query:
An example of input for US states:
Example 3 — get an input SELECT statement with parameters for the SELECT statement:
Note: When exposing the SQL statement as an external parameter for the user, ensure it runs on a read-only DB connection to prevent any DB updates.
A new generic Custom Logic flow, CustomLogicSql has been added to the TDM library. This flow executes a given SQL query on a specified DB interface. Edit the flow in order to use it in TDM tasks:
The following parameters can be set by the task creator:
The CustomLogicSql flow runs in a direct call mode.
Populate both parameters — sql and sqlParams:
sql:
select distinct cust.customer_id from customer cust, activity act, cases cs where cust.customer_id = act.customer_id and act.activity_id = cs.activity_id and cs.status = ? and cs.case_type = ?
sqlParams:
Open,Billing Issue
Populate only the sql parameter:
sql:
Select Distinct act.customer_id From activity act, cases ca Where act.activity_id = ca.activity_id And ca.status <> 'Closed' And ca.case_type in ('Device Issue', 'Billing Issue');
Add the LU name and Custom Logic flow name to the CustomLogicFlows constTable TDM Actor (imported from the TDM library).
View the below example:
Check the DIRECT_FLOW checkbox to enable Direct Call of the Custom Logic flow.
Redeploy the Web Services.
This article outlines the implementation of a Custom Logic flow that generates an entity subset for task execution. One or more Broadway flows can be designed to define the logic, which ultimately produces an output list of entity IDs. During task execution, this list is returned and used by the TDM process to extract or load data.
TDM supports two execution modes for running Custom Logic flows: Direct Call and Indirect Call. These modes define how the list of entities is retrieved and processed by a task’s batch process.
Direct Call Mode — in this mode, the batch process triggers the Custom Logic flow at runtime, which immediately returns the list of entities. The entities are streamed directly from the flow, without any intermediate storage or preloading.
The Custom Logic flow must contain only one DbCommand with a single SELECT query that retrieves the entity list. Additionally, the associated Business Entity must include only one Root LU. For Business Entities with multiple Root LUs the Indirect Call mode should be used instead.
The task processes entity IDs in data chunks as they are retrieved, without waiting for the full list to load. This streaming approach significantly improves performance when working with large datasets.
Indirect Call Mode — in this mode, the Custom Logic flow runs before the batch process begins, generating a list of entity IDs and storing them in a temporary table within the TDM database. This table is created specifically for the task execution, following the naming convention entity_list_<task exe_id>
.
Unlike Direct Call, the entire entity list is written in advance, and the task retrieves entities by querying this table during execution. Once processing is complete, the table is automatically removed.
Indirect Call supports complex scenarios, such as Business Entities with multiple Root LUs that require a unified list of entities. It is also useful when the entity list needs to be reviewed, reused, or further processed before task execution.
The Custom Logic Broadway flow can be created in either the Shared Objects or a given LU.
The Custom Logic Broadway flow always includes two external input parameters, whose values are provided by the task execution process:
TDM supports the creation of additional external parameters in the flow, enabling the user to send the values of these parameters in the TDM task. For example, you can add an external parameter named customer_status to the flow. The flow then selects customers for the task based on this input parameter. This way, you can filter customers by their status and still use the same flow to select them.
Notes:
The input parameter name must not contain spaces or double quotes.
TDM V8.0 introduced integration of Broadway editors into the TDM portal when populating either data generation or Custom logic parameters in the task tabs. This integration enables users to select valid values from a list, set dates, and configure distributed parameters.
Click here for more information about TDM integration with Broadway editors and related implementation instructions.
Sending multiple values in one parameter — you can define a String input parameter to provide a list of values, which the Broadway flow can split into an array using a specified delimiter (e.g.,"CA,NY"). The delimiter is configured in the split Actor within the flow.
You can define a SELECT statement as an input argument. The SELECT statement can have binding parameters. The parameter values can be provided either through separate input parameters or directly within the SELECT statement. See the CustomLogicSql flow's examples below.
A Direct Call Custom Logic flow should have the following structure:
Init — calls the TDMSetSessionGlobals Actor to run the initial setting for the Custom Logic flow execution. The SESSION_GLOBALS input parameter must be defined as an external parameter named SESSION_GLOBALS.
DbCommand — defines the SELECT statement to select the task entities. The SELECT statement must return only the entity IDs.
customLogicDirectFlowUtil — filters out the reserved entities if needed, and formats the entity IDs for the task execution:
Stage 1:
Stages 2-4: Loop on the selected entities — set a Transaction within the loop to ensure a single commit for all iterations:
Stage 2: Set the selected entity ID — returned by the Actor of Stage 1 — to a String using the ToString Actor.
Stage 3: Call the CheckReserveAndLoadToEntityList TDM Broadway flow (imported from the TDM library):
Input — LU_NAME parameter. This is an external parameter, whose value is populated by the task execution process.
Output — recordLoaded. This is the entity number counter, which is loaded into the entity table.
This flow executes the following activities on each selected entity ID:
Stage 4: Call the CheckAndStopLoop TDM Actor (imported from the TDM library). Set the NUM_OF_ENTITIES to be an external input parameter, whose value is populated by the task execution process. This Actor checks the number of entities inserted to the entity table, and stops the loop if the custom flow reaches the task's number of entities.
Example:
The task needs to retrieve 5 entities. The SELECT statement selects 20 entities. The first 2 selected entities are reserved for another user. The 3rd, 4th, 5th, 6th, and 7th entities are available and are populated in the entity table; the entity loop then stops.
Examples of a Custom Logic flow are shown below:
Example 1 — get the Contract Status as an input parameter and build the SELECT statement accordingly:
Example 2 — get an input String of states, separated by a comma. Split the input String into an array and send it to the SQL query:
An example of input for US states:
Example 3 — get an input SELECT statement with parameters for the SELECT statement:
Note: When exposing the SQL statement as an external parameter for the user, ensure it runs on a read-only DB connection to prevent any DB updates.
A new generic Custom Logic flow, CustomLogicSql has been added to the TDM library. This flow executes a given SQL query on a specified DB interface. Edit the flow in order to use it in TDM tasks:
The following parameters can be set by the task creator:
The CustomLogicSql flow runs in a direct call mode.
Populate both parameters — sql and sqlParams:
sql:
select distinct cust.customer_id from customer cust, activity act, cases cs where cust.customer_id = act.customer_id and act.activity_id = cs.activity_id and cs.status = ? and cs.case_type = ?
sqlParams:
Open,Billing Issue
Populate only the sql parameter:
sql:
Select Distinct act.customer_id From activity act, cases ca Where act.activity_id = ca.activity_id And ca.status <> 'Closed' And ca.case_type in ('Device Issue', 'Billing Issue');
Add the LU name and Custom Logic flow name to the CustomLogicFlows constTable TDM Actor (imported from the TDM library).
View the below example:
Check the DIRECT_FLOW checkbox to enable Direct Call of the Custom Logic flow.
Redeploy the Web Services.