---
title: "Using actions to run workers, create child tasks and trigger parent tasks"
slug: "using-actions-to-run-workers-create-child-tasks-and-trigger-parent-tasks"
updated: 2025-08-04T09:43:28Z
published: 2025-08-04T09:43:28Z
canonical: "support.lusid.com/using-actions-to-run-workers-create-child-tasks-and-trigger-parent-tasks"
---

> ## Documentation Index
> Fetch the complete documentation index at: https://support.lusid.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Using actions to run workers, create child tasks and trigger parent tasks

You can define an action to be taken on completion of a state transition within a [task definition](/v1/docs/how-do-i-create-a-task-definition) in the Workflow Service. There are currently three types of actions available for you to use in a task definition to provide further functionality to your workflow:

For example, you could use actions to help model the following workflow in a task definition:

![](https://cdn.document360.io/d575ad81-c0ed-4980-bbd1-d59ac5c3de82/Images/Documentation/image(1).png)

## Pass input parameters into and kick off a worker using `RunWorker`

You can use the `RunWorker` action in your task definition to kick off a run of a worker you have created in the Workflow Service. [See how to create a worker.](/v1/docs/how-do-i-create-a-worker)

![](https://cdn.document360.io/d575ad81-c0ed-4980-bbd1-d59ac5c3de82/Images/Documentation/image(2).png)

For example, you might configure a `RunWorker` action in your task definition to kick off a worker that checks quotes for outliers after they're imported into LUSID. To do this, call the [CreateTaskDefinition](https://www.lusid.com/docs/api/workflow/endpoints/task-definitions/CreateTaskDefinition) or [UpdateTaskDefinition](https://www.lusid.com/docs/api/workflow/endpoints/task-definitions/UpdateTaskDefinition) API and, within `actions`, pass in:

- A `name` that uniquely identifies the action within the task definition.
- The action `type`, which is `RunWorker`.
- Optionally, a value for `runAsUserId` to perform the action on behalf of a service user. [Read more about this.](/v1/docs/setting-up-a-schedule-subscription-or-other-activity-on-behalf-of-a-service-user)
- The `scope` and `code` of the worker that this action should kick off.
- Any triggers to prompt a task state transition depending on the outcome of the worker. You can configure the action to trigger a state transition when or if the worker:
  - Starts using `started`.
  - Completes and outputs at least one row of results using `completedWithResults`.
  - Completes and outputs no rows using `completedNoResults`.
  - Fails to start using `failedToStart`.
  - Fails to complete using `failedToComplete`.
- Mapping for the worker input parameters. For each [Luminesce view](/v1/docs/how-do-i-create-a-worker) input parameter name, specify the name and *either*:
  - Use `mapFrom` to map the input parameter value from a particular task field.
  - Use `setTo` to set the input parameter to a particular value.
- Any child tasks which should be created for the worker results. Each child task configuration should include the following:
  - The `scope` and `code` of the task definition for each child task.
  - Optionally, a `resultMatchingPattern` [using LUSID's filtering syntax](/v1/docs/filtering-information-retrieved-from-lusid). If omitted, one child task is created for each row of the worker results. If `resultMatchingPattern` is specified, child tasks are created for a subset of the worker results. **Note:** If there are multiple `childTaskConfigurations` specified in one action, one of each of the child task configurations is created for each row of results (if it meets the `resultMatchingPattern`). Once a worker run has completed with results, all subsequent child tasks are created at once.
  - The `trigger` the child task should be prompted with as soon as it is created.
  - Mapping for the task fields of one or more child tasks. For each child task field, specify the name and *either*:
    - Use `mapFrom` to map the task field value from a particular worker result.
    - Use `setTo` to set the task field value to a particular value.

This portion of the API request might look like this:

```json
...
"actions": [
  {
    "name": "quote-outliers-check-worker",
    "actionDetails" : {
      "type": "RunWorker",
      "workerId": {
        "scope": "Finbourne-Examples",
        "code": "Check-Quotes-For-Iqr-Outliers"
      },
      "workerStatusTriggers": {
        "completedWithResults": "exceptionsFound",
        "completedNoResults": "noExceptions"
      },
      "workerParameters": {
        "StartDate": {
          "MapFrom": "iqrQuoteRangeStartDate"
        },
        "EndDate": {
          "MapFrom": "iqrQuoteRangeEndDate"
        },
         "PfolioScope": {
          "SetTo": "Finbourne-Examples"
        },
         "PfolioCode": {
          "MapFrom": "portfolioCode"
        }
      },
      "childTaskConfigurations": [
        {
          "taskDefinitionId": {
            "scope": "Finbourne-Examples",
            "code": "Quote-Outliers-Exception"  
          },
          "initialTrigger": "start",
          "childTaskFields": {
            "clientInternal": {  "mapFrom": "ClientInternal" },
            "lowerLimit": {  "mapFrom": "LowerLimit" },
            "upperLimit": {  "mapFrom": "UpperLimit" },
            "price": {  "mapFrom": "Price" },
            "priceDate": {  "mapFrom": "PriceDate" },
          }
        }
      ]
    }
  }
   ]
   ...
```

## Create one or more tasks as a child of the current task using `CreateChildTasks`

You can use the `CreateChildTasks` action in your task definition to create one or more tasks as a child of the current task on completion of a state transition.

![](https://cdn.document360.io/d575ad81-c0ed-4980-bbd1-d59ac5c3de82/Images/Documentation/image(3).png)

For example, you might configure a `CreateChildTasks` action in your task definition to create a child task to check quotes for outliers after they're imported into LUSID. To do this, call the [CreateTaskDefinition](https://www.lusid.com/docs/api/workflow/endpoints/task-definitions/CreateTaskDefinition) or [UpdateTaskDefinition](https://www.lusid.com/docs/api/workflow/endpoints/task-definitions/UpdateTaskDefinition) API and, within `actions`, pass in:

- A `name` that uniquely identifies the action within the task definition.
- The action `type`, which is `CreateChildTasks`.
- Optionally, a value for `runAsUserId` to perform the action on behalf of a service user. [Read more about this.](/v1/docs/setting-up-a-schedule-subscription-or-other-activity-on-behalf-of-a-service-user)
- The `scope` and `code` of the task definition that this action should use when creating a child task.
- Mapping for the values of child task fields. For each child task field, specify the name and *either*:
  - Use `mapFrom` to map the child task field value from a particular parent task field.
  - Use `setTo` to set the child task field value to a particular value.
- The `trigger` the child task should be prompted with as soon as it is created.

This portion of the API request might look like this:

```json
...
"actions": [
  {
    "name": "trigger-control-outliers-child-task",
    "actionDetails": {
      "type": "CreateChildTasks",
      "childTaskConfigurations": [
        {
          "taskDefinitionId": {
            "scope": "Finbourne-Examples",
            "code": "Control-Outlier-Quotes"
          },
          "childTaskFields": {
            "iqrQuoteRangeStartDate": {  "mapFrom": "iqrQuoteRangeStartDate"},
            "iqrQuoteRangeEndDate": {  "mapFrom": "iqrQuoteRangeEndDate"},
            "portfolioScope": {  "setTo": "Finbourne-Examples"},
            "portfolioCode": {  "mapFrom": "portfolioCode"}
          },         
          "initialTrigger": "start"
        } 
      ]
    }
  }
   ]
   ...
```

Note that you can create a child task for the results of a worker instead of on completion of a state transition; this must be configured within a `RunWorker` action. [See how to do this.](/v1/docs/using-actions-to-run-workers-create-child-tasks-and-trigger-parent-tasks#pass-input-parameters-into-and-kick-off-a-worker-using-runworker)

## Trigger a state transition for the parent of the current task using `TriggerParentTask`

You can use the `TriggerParentTask` action in your child task definition to trigger a state transition for the parent of the current task.

![](https://cdn.document360.io/d575ad81-c0ed-4980-bbd1-d59ac5c3de82/Images/Documentation/image(59).png)

For example, you might configure a `TriggerParentTask` action in an “exception” child task definition to resume the parent task once the exception has been resolved. To do this, call the [CreateTaskDefinition](https://www.lusid.com/docs/api/workflow/endpoints/task-definitions/CreateTaskDefinition) or [UpdateTaskDefinition](https://www.lusid.com/docs/api/workflow/endpoints/task-definitions/UpdateTaskDefinition) API and, within `actions`, pass in:

- A `name` that uniquely identifies the action within the task definition.
- The action `type`, which is `TriggerParentTask`.
- Optionally, a value for `runAsUserId` to perform the action on behalf of a service user. [Read more about this.](/v1/docs/setting-up-a-schedule-subscription-or-other-activity-on-behalf-of-a-service-user)
- The `trigger` the parent task should be prompted with.

This portion of the API request might look like this:

```json
... 
"actions": [
     {
       "name": "trigger-control-outliers-parent-task",
       "actionDetails" : {
         "type": "TriggerParentTask",
         "trigger": "resolved"
       }
     }
   ]
   ...
```

Movement from one state to another in the Workflow Service. Each state transition includes a start state, end state and is prompted by a trigger.

Modelled as a Mealy state machine, a sequence of states and actions which encapsulate a workflow (or part of a complex workflow). Within a task definition, you can configure parameters for a task, such as states, fields and allowable state transitions. Task definitions also include actions, which can run workers to interrogate your data and generate child tasks. The task definition determines what a particular task does when an instance of that task occurs.

Units of functionality in the Workflow Service which can access LUSID data. Called by tasks, workers take input parameters mapped from the fields of a task, and return results which can be mapped to a task definition. Worker status can be used to trigger a parent task automatically.

Defined within a state transition, a prompt which induces a state transition to occur in the Workflow Service.

The way in which data is passed into, around and out the other end of the task in the Workflow Service. Field names and data types are completely customisable and can be defined in a task definition. Field values can be specified when creating or updating a task.

An occurrence of the workflow defined in a task definition. You can create multiple tasks from one task definition, typically with changing input values, for example you might create one task per LUID for securities to be screened.
