Trigger automation 🔒

Trigger an app action automation from another automation

As outlined on the Triggers page there are a variety of ways to trigger an automation.

In particular the App action trigger allows an End User to directly trigger an automation. It is also possible to call these app action automations from another automation. This is done with the Trigger an automation step.

Select an Automation (only app action automations will be available). Next you will see the fields from the target automation that must be filled out. In this case it is just the employee_id.

App action trigger of the target automation

App action trigger of the target automation

Optionally set the Timeout (ms) if you want to make use of the response.

Using the output

There are a couple of useful bindings that are provided by the trigger an automation action step.

Selecting the trigger automation outputs

Selecting the trigger automation outputs

Available bindings

Available bindings

  • Success - a boolean field that indicates if the triggered automation passed or errored
  • Value - the object representing the output of the target automation


Tutorial: Generating onboarding tasks for new employees

In this tutorial we will use automations to generate onboarding tasks from a template table whenever a new employee is added.

The app export for the tutorial can be downloaded here. The download may take a few seconds.

Data

Create three tables. See Budibase DB for more on the available data types.

Table nameColumns
Employeesfirst_name: Text,
last_name: Text,
hired_date: Date
OnboardingTasksdate: Date
OnboardingTaskTemplatestitle: Text,
description: Text

With our tables created, we need to create Relationships between them as follows:

  • One Employee -> Many OnboardingTasks
  • One OnboardingTaskTemplate -> Many OnboardingTask

Finally create a static Formula column in the OnboardingTask table. Set this value to the Template Relationships title field:

In the Design section, create two autogenerated screens for the Employees and OnboardingTasks tables.

Automation

The automation section is now where we are going to generate onboarding tasks from our templates whenever a new employee is created.

  1. First create a new App action automation, and Add field employee_id.
  2. Add a Query Rows step and select the OnboardingTaskTemplates table
Get all the onboarding task templates

Get all the onboarding task templates

  1. Add a Create Row step for the OnboardingTasks table, and Add Looping.
    1. The Input type should be Array, and the Value should be the output of our templates query: {{ steps.1.rows }}
  2. Now fill out the values for the OnboardingTask fields:
    1. Date: return new Date() (JavaScript binding)
    2. Template: {{ loop.currentItem._id }}
    3. Employee: {{ trigger.fields.employee_id }}

We now have an automation that will create onboarding tasks from our templates, but we still need to trigger this automation. We will do this from a second automation:

  1. Create a new automation with a Row Created trigger. Select the Employees table
  2. Add a Trigger an automation action step. Select the first automation we created earlier, and provide the employee_id Binding: {{ trigger.id }}

Publish your app to test out the workflow!

Result

Creating a new employee

Creating a new employee

Generated onboarding tasks

Generated onboarding tasks