Automated workflows - agileChilli
agileBase has a number of workflow features built in that get a lot of use. they work with any app you build using the platform and cover things like auto-setting field values on creation, sending notifications, moving data between views etc.
agileBot can be set up to follow rules for creating new records, editing values in existing records or taking other actions. The rules can be simple or complex, in fact anything that can be represented by a standard view, which makes it really powerful.
This can be used in conjunction with other workflow features such as the ability to send email notifications or generate documents, and many steps can be chained together. Many business processes can therefore be fully automated.
- If the system stores recipes, whenever an allergen is changed, a product spec. doc can be generated and emailed to significant customers
- Automatic invoicing – whenever billable events are added to the system, invoices can be generated and emailed to customers or to your account packages
- Automated todo’s – when a lead hasn’t had any activity in 2 weeks, add a todo to the relevant salesperson’s diary to follow up, syncing to their Google calendar
Creating a rule
Here are the basics.
1) A rule is represented by a view. First create the view to represent the rule. The rule can prompt many actions:
- create a new record
- edit an existing record
- remove a record
- lock a record so it can’t be edited by users in future
- push data to a third party system (using the API)
- generate a document
- send an email
2) Any records which become visible in your rule view will trigger the action selected. So add filters (on a calculation if necessary) to select only the records you wish to trigger the action.
3) If creating or editing a record, the fields in the view will populate the new or existing record. Any fields in the view with the same name as a field in the table will populate that field with it’s data. The view field can be a calculation as well as a standard field.
4) Once the view’s created, go to manage -> workflow
Fill in the options. For ‘Recording the time of the last action’, select a date field in the table the view’s based on. This date will be updated every time the workflow runs. If there’s no relevant date field existing, add one to the table.
Complex sets of rules can be created by chaining workflows together. Each workflow will be set to follow on from the last – for example invoice creation may comprise creating the invoice record and lines, generating a PDF and emailing it to a customer.
If a workflow is kicked off manually (see below), the ID of the record is passed as a filter from one workflow step to another, to ensure all workflow steps operate on the same record.
Workflow steps can also be set to ‘recurse’ i.e. run over and over again until there are no more records left to process, before moving on to the next step. This can be useful for recursive actions such as e.g. adding an allergen to an ingredient, which may then require also adding that allergen to all recipes that include it.
When do workflows run
Workflows can be set to run at a particular frequency, either every 24 hours, every hour, half hour, ten minutes or five minutes.
They can also be set to be run manually by a user – see below.
Finally, a workflow can be set to run whenever a new record is created in a table, or even whenever an existing record is loaded by a user. To set up these last two options, see the Options section under the Manage tab of a table.
These options allow workflows to be useful in many different situations.
Manual ‘action’ buttons
You may know of workflows, or automations in agileBase. These are automatic tasks that run in the background, to do things like send emails from the system, generate PDF documents or create/update records.
Due for release tomorrow is a new feature that leverages the workflow engine to massively increase the power of the user interface.
In short, you can now create workflow actions that can be run ‘manually’, from buttons in the user interface, rather than automatically in the background. Furthermore, you can chain actions together, to make multi-step workflows that run at the click of a button.
An example is the ‘print labels’ button here.
Each step in the workflow can do one of these tasks:
- create new records with specified values
- edit values in existing records
- remove records (if there are no dependencies)
- lock records to prevent further editing
- generate PDF files from data in the system, based on a template
- send emails, merging in data from the system
- send data to a third party calendar, e.g. Google calendar or Office 365
- push data to a custom third party system using the API
So for example, if your system receives customer orders that need to be produced on the factory floor, you can create an automation that takes a snapshot of all the orders so far and generates production sheets for the quantities required. It can then be run multiple times a day on demand to pick up new orders.
Developers commonly wish to have ways of manually interacting with third party applications, e.g. to send data to a custom app for processing, this should be very useful for them too.
To set up a button, first create a workflow as normal, using the ‘workflow’ button in a view’s ‘manage’ tab.
For the frequency, rather than say ‘run workflows every 10 minutes’, select ‘manually’.
Note: to chain workflows together, select a workflow name under ‘chain workflow’. That workflow will run as soon as the first completes. You can chain as many as you like together. Remember to set frequency to ‘manual’ for all of them.
Finally, create a button. This is simply a matter of selecting a view where you want the button to appear. When the user clicks that view in a tile, the button will appear above.
In the manage tab for that view, under ‘chain workflow’, choose the workflow view that should be run (the start of the chain if there’s more than one in the chain).
If you want your workflow to set the value of a relation find, i.e. link to a particular record, there’s no need to create a calculation for it, just include the ID field for the record you want to link to in the view.
If creating a calculation is easier, you can still do that. Either create a numeric calculation which outputs the internal row ID of the record to link to, or the text of the primary value for the relation. If the latter case, the field for the primary value in the related table should be unique and marked as such in the field options.
To set a relation field to blank, add a numeric calculation with the name of the field as normal, but set it to output the value -1.