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.
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.
- 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 name | Columns |
---|---|
Employees | first_name: Text ,last_name: Text ,hired_date: Date |
OnboardingTasks | date: Date |
OnboardingTaskTemplates | title: 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.
- First create a new App action automation, and
Add field
employee_id. - Add a Query Rows step and select the OnboardingTaskTemplates table
- Add a Create Row step for the OnboardingTasks table, and Add Looping.
- The Input type should be
Array
, and the Value should be the output of our templates query:{{ steps.1.rows }}
- The Input type should be
- Now fill out the values for the OnboardingTask fields:
- Date:
return new Date()
(JavaScript binding) - Template:
{{ loop.currentItem._id }}
- Employee:
{{ trigger.fields.employee_id }}
- Date:
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:
- Create a new automation with a Row Created trigger. Select the Employees table
- 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
Updated 9 months ago