When creating automation rules in Memento Database, proper configuration of the basic settings is crucial for their effective operation. These fundamental settings determine when and how your rules will execute.
Basic Rule Configuration
When creating a new rule, you’ll need to configure three primary settings:
- Rule Name
- Condition
- Execution Mode
Setting a Rule Name
The rule name should be descriptive and clearly indicate the rule’s purpose. A well-chosen name helps you identify and manage rules, especially as your automation system grows more complex.
Configuring Rule Conditions
The condition determines when your rule should execute. Memento Database offers two powerful ways to define conditions:
1. Using Entry Filters
For triggers and actions that operate in the context of an entry, you can use entry filters to define conditions. This method is intuitive and similar to the filtering interface you use when viewing entries.
To use a filter condition:
- Click the filter icon at the beginning of the condition field
- Configure your filter criteria just as you would when filtering entries in a list
- The rule will only execute for entries that match these filter criteria
Filter conditions are excellent for:
- Rules that should only apply to certain categories of entries
- Conditions based on multiple fields
- Complex conditions with multiple criteria
2. Using Expressions
For more dynamic conditions, you can use expressions. An expression condition must start with an equals sign (=) and can reference fields in the current entry.
How to create an expression condition:
- Start the expression with an equals sign (=)
- Build your expression using:
-
- Field references: #{field name}
- Comparison operators
- Arithmetic operators
- JavaScript-compatible functions
Field References:
Use the syntax #{field name}
to reference a specific field in the current entry. Make sure the field name matches exactly.
Supported Operators:
You must use the following comparison operators, which are directly translatable to JavaScript:
> (greater than)
< (less than)
== (equal to)
!= (not equal to)
Additionally, you may use other standard JavaScript operators, including:
- Arithmetic: + , – , * , / , %
- Logical: &&,||, !
- Grouping: Parentheses () to control order of operations
Example Expressions:
=#{count} < 10
– The rule will execute if the “count” field is less than 1=#{price} * #{quantity} > 1000
– The rule will execute if the total value exceeds 1000=#{status} == "active" && #{loginAttempts} < 5
– The rule will execute if the status is “active” and login attempts are fewer than 5
All expressions are evaluated as JavaScript code under the hood.
Configuring Execution Mode
The execution mode determines how the rule processes entries. There are three options:
1. Single Execution
The rule processes only the current entry. This is the most common mode and is suitable for rules that:
- Modify the current entry
- Perform validation on entry data
- Execute simple actions related to the current entry
2. Run For Each
This mode executes the rule’s tasks for multiple entries in a loop. After selecting this mode, you must specify which entries to process:
- Entries in the current library – Process all or filtered entries in the same library
- Entries in another library – Process entries from a different library
- Related entries – Process entries that are linked to the current entry
The Item Alias parameter lets you define a name for each item in the loop, which you can reference in the rule’s tasks. For example, if you’re processing all customer entries, you might set the alias to “customer” to access each customer entry during the loop.
After setting up which entries to process, you’ll see a new Loop Condition field. This allows you to further filter which loop items will be processed. For example, if you’ve set up the rule to run for all entries in your Tasks library, you could add a loop condition to only process tasks with “Priority = Low”.
This execution mode is perfect for:
- Batch updating multiple entries
- Generating reports across entries
- Processing related entries (like updating all items in an order)
3. On Demand
Rules with this execution mode only run when explicitly called from other rules or tasks. They don’t execute automatically based on events.
A common use case is with dialog tasks – you can create an “On Demand” rule that executes when a button in a dialog is pressed.
Adding Tasks to Rules
After creating and configuring your rule, you need to add tasks that will be executed when the rule is triggered. To add tasks:
-
Android
-
Desktop
- Click the + button in the rule header
- Select the type of task you want to add (such as "Write Field Value," "Create Entry," "Show Message," etc.)
- Configure the task's settings
- Add as many tasks as needed to accomplish your automation goal
- Select a rule and click the New Task
- Choose the type of task you want to add (e.g., Write Field Value, Create Entry, Show Message, etc.).
- Configure the task's settings.
- Add additional tasks as needed to complete your automation setup.
Tasks will execute in the order they appear in the rule. You can reorder them by dragging if needed.
Testing Rules
Memento Database allows you to test your rules directly from the editing interface:
- Configure your rule with conditions and tasks
- Click the Play button in the top-left corner of the rule editing screen
- The rule will execute immediately using your actual library data
Important Warning: When testing rules, they execute on your real library data. If your rule includes tasks that modify or delete entries, these changes will actually be applied to your database. Be cautious when testing rules with destructive actions, especially in production libraries containing important data.