Example: Execution from custom tasks
After you create the integration object record, you can use a custom task to filter an outbound query with data from the currently running process.
Background
Ichiro is an integration specialist at Company ABC. He develops IBM® TRIRIGA® integrations for the customers of Company ABC.
Ichiro updates a subset of records, but he wants an integration to send a record when a
user clicks a particular action. So he uses a special Custom task object that uses workflow
variables to set data, and that communicates with the Integration
class
loader record. By using this feature, Ichiro can build the subset of records in the workflow
by using the common methods. Then, he can pass the subset by referring to the Custom task,
and assign the integration object record that he wants to trigger to a workflow variable
named IntegrationObject
.
- Start task
- Query task that is named
Query For Integration Object
- Variable Definition task that is named
IntegrationObject
- Variable Definition task that is named
IntegrationInstance
- Query task that is named
Query for subset of people
- Custom task that is named
Custom Task
- End task
Step 1: Define the workflow
Ichiro selects the Start task, sets the workflow as asynchronous, and sets the workflow to
run when a person record (triPeople
) is saved
(triSave
).
Step 2: Define the first Query task
Ichiro inserts the first Query task and names it Query For Integration
Object
. In this task, he queries (Manager Default - Integration
Objects
) for the integration object record that he wants to trigger. Then, he
filters the results of this query for a specific name. Ichiro must have only one resulting
integration object record.
Step 3: Define the first Variable Definition task
Ichiro inserts the first Variable Definition task and names it
IntegrationObject
. In this task, he defines the integration object record
(triIntegration
) as a variable. The result of the query from the previous task is
assigned to this variable.
Step 4: Define the second Variable Definition task
Ichiro inserts the second Variable Definition task and names it
IntegrationInstance
. In this task, he defines the integration instance
object (triIntegrationInstance
) as a variable. This return variable is used
for the return value from the Custom task at the end of the workflow.
Step 5: Define the second Query task
Ichiro inserts the second Query task and names it Query for subset of
people
. In this task, he obtains the filtered set of people records that are
processed for the integration. He queries (triEmployee – Find
) for the
people records. Then, he filters the results for records where the person's given name
(triFirstNameTX
) contains Ichiro
.
Ichiro verifies that the people business object (triPeople
) contains the
record ID (triRecordIdSY
) field. For any business object that is used in
the Query task that is passed to the integration object record, the record ID
(triRecordIdSY
) field must be included. When an integration is running,
the integration object record uses the record ID to retrieve the remaining fields in the
business object that is defined in the data map.
Step 6: Define the Custom task
Ichiro inserts the special Custom task that uses workflow variables to set data, and that
communicates with the Integration
class loader record. In this task, he
passes the results of the Query for subset of people
task as the set of
records. Finally, Ichiro adds the return variable that is needed to obtain the integration
instance record. The name of the return value must be
IntegrationInstance
.
- The Class Name field for the Custom task is set to
Integration:com.tririga.custom.integration.Parameter
. This class name must be used when this method is implemented. TheParameter
class inside of theIntegration
class loader path implements theCustomParamBusinessConnectTask
Java Interface class with the following signature:public CustomParamTaskResult execute(TririgaWS client, Map params, long userId, Record[] records)
- The
params
argument represents the assignedIntegrationObject
variable so that the process has the instructions that it needs to continue the integration. Therecords
argument represents the Records section in the Custom task where the records to use for the workflow process are assigned. Instead of triggering the event on one object, two sets of objects are being passed to an event. - The
Parameter
class looks for the integration object record from theIntegrationObject
variable and processes the results in therecords
argument that are passed. This processing includes running the query from the Query for Outbound section of the integration object record and filtering by the record IDs of the records that are passed. As a result, data is being exported with the common utilities. But the export is no longer bound by all-or-nothing queries, or by triggering the event directly from the Execute form action. - Outbound integrations that are executed from the
Parameter
class can process a maximum of 1000 records at one time, or 999 records at one time for XML or JSON format. If more than 1000 records must be exported, you can select the Exceed Custom Task Parameter 1000 Result Limit and Return Maximum? option. This option will also exceed the 999 result limit for XML and JSON formats. Because more memory will be used as the result set gets larger, system performance should be considered when selecting this option with larger result sets. For another way to exceed the 1000 result limit for theParameter
class, see the following section "Batch the query results" to create workflow logic that can run your integration in batches of 999 results until all of the records are processed.
Batch the query results
If there are more than 999 records to be exported, create your workflow logic to batch the query results into batches of 999, by performing the following steps:
- 1. Create a variable that will be used to manage the batching of the query results. For example, Var Batched Query Results. The Module and Object field values will be the module and query from Step 5.
- 2. Create an Iterator task that will iterate the results of the query from Step 5. Within the Iterator task, add an Assign Variable task to append each result to the Var Batched Query Results variable. Make sure that the Append Results check box is selected.
- 3. Create a Switch task that will be used to control each batched result. The expression will check for when the Var Batched Query Results variable result count is equal to 999.
- 4. Within the Switch task, add the Custom task that calls the integration object record. Make sure that the Records section of this Custom task specifies the Var Batched Query Results variable. Also make sure that the integration object record (called by this Custom task) does not have the Overwrite check box selected. The integration object record will also be designed with the Is Dynamic check box selected within the Query for Outbound section. The fields intended for export will be specified in the Data Map tab.
- 5. Still within the Switch task, add an Assign Variable after the Custom task. This will be used to clear the results of the Var Batched Query Results variable after the Custom task is run. This will also prepare the Var Batched Query Results variable for the next batch of 999 results.
- 6. After the Iterator task, add another Switch task. This will be responsible for processing the remaining results. The expression will check for when the Var Batched Query Results variable result count is greater than 0.
- 7. Within this Switch task, call the same Custom task that was added above.
Note that this process will not create one file. It will create one or more batched files of 999 records each, plus a final file with the remainder.