Triggers are basically notifications that you get when a specific event happens within your database tables. Here, we’ll use the Product Table as an example for the purpose of our guide.
To add a new trigger, go into the “Triggers” section of your table settings, and then select “Add new trigger” in the top right hand corner of your window.
You can create three different kinds of triggers:
On Create/Update
Add to Timeline
Schedule Trigger
The Trigger window is split into 3: First, you will find your basic settings, then you will choose your triggers’ criteria, and finally, you will set your triggers’ action.
On Create/Update
Give your trigger a name, and define the event for which you want the trigger to activate.
Event- “On Create/Update” sends you a notification whenever a defined event happens- in this case, when something in your table is created or updated.
For example, if you want to generate a trigger for every time a new product is created in your Product Table, you may name your trigger “Create_Product”, and check off “Create” under the Event dropdown menu.
This is very general, but you can make this trigger more specific by selecting “Add new criteria”.
Say you only want a trigger to happen when products that cost $30 or above are added to the Product Table. You can define your Field Name as “Price,” “greater than or equal to” as your Criteria, and set the Value to 30. Then hit Apply.
After this, you must define the action you want to happen when the trigger goes off. To do this, click “Add new action” on the lower half of your Trigger Settings window. The following window will open:
As you can see from the top dropdown menu, there are three kinds of actions:
Notification
HTTP
If you choose “Notification,” the trigger will show up in the app itself (in this case, in the Product Catalog).
You can define if you want the trigger to happen when anyone creates a new product, by ticking “Field” and selecting “CreatedBy.” However, you also have the option of getting a notification only if a specific user creates a new product, by ticking “Fixed” and selecting the name of the user.
Under “Notification content”, you can write any message that you’d like to receive in your notification toolbar. For example, you can write “New product added: ”, which tells the trigger to display the name of the new product added.
Then, select the icon under which you’d like your notifications to appear, define the icon color, and then make sure to hit “Apply”.
As you can see in the image above, the notifications will appear in the top right corner of the Product Catalog.
From here on out, any time a product is created that costs more than $30, you will get a notification on your Product app. Note that you can “Snooze” the notification, but it will not go away until you hit “Dismiss.”
If you choose “Email” as your trigger action, the following window will appear:
Before you set this up, make sure the user’s email settings are defined in the User Table. If they haven’t been already, you must configure the user’s SMTP as in accordance with his email provider’s guidelines. We will show you an example using Gmail (this can be done with Yahoo, Hotmail, and other email providers as well.)
Go into “Users” in your database, and click on a username to edit. Then, click “Email settings” on the top right-hand corner of the window.
“SMTP Server”: This is the email account’s SMTP server address. For a Gmail account, insert smtp.gmail.com
“SMTP User”: Enter the full email address from which you wish to send out automatic emails (the email address associated with the user’s Mybusiness account).
“SMTP Password”: Enter the email address password.
“SMTP Port”: Enter the SMTP port of the email provider. For Gmail, enter 465 or 587.
“Sender Name”: Enter the name that you want to appear on the trigger emails (usually your name).
“Sender Email”: Enter the email address that you want the trigger to appear to be sent from (this can be the same as your actual email address).
Now, back to the email trigger.
Select which template to use for the body of the email. (Note that you may create your own template in the “EmailTemplate” Table of your database using HTML.)
Then, click the dropdown menu under “From User Mail” to define from which user’s email address you want the email to appear to be sent.
Choosing “Field” will send the email to the user who created or updated the Product Table (by selecting the Created.By or Updated.By field), while choosing “Fixed” will define that the trigger be sent to one, fixed email of your choosing.
In “Email Subject,” put the email subject line of your trigger. When you are finished, click “Apply.”
Your third action option is “HTTP.” This will send the data of your trigger as JSON data.
Under “URL,” insert the link of the website or application that you wish to receive the data.
For “Method,” you can select “AUTO” if you want the action counterpart of your trigger to adapt to it automatically (for example, if you’ve set your trigger to be on “Create,” the Method would be POST,” but if you’ve set your trigger to be on “Update,” the Method would be “PUT.”)
You may also choose a fixed Method for each trigger, such as “GET” or “DELETE.”
Under “Additional Headers,” you may add additional custom headers to the request, by inserting the Key and the Value.
When you are finished, click “Apply.”
Under “URL,” insert the link of the website or application that you wish to receive the data.
For “Method,” you can select “AUTO” if you want the action counterpart of your trigger to adapt to it automatically (for example, if you’ve set your trigger to be on “Create,” the Method would be POST,” but if you’ve set your trigger to be on “Update,” the Method would be “PUT.”)
You may also choose a fixed Method for each trigger, such as “GET” or “DELETE.”
Under “Additional Headers,” you may add additional custom headers to the request, by inserting the Key and the Value.
When you are finished, click “Apply.”
Add To Timeline
The second kind of trigger you may create when adding a new trigger is “Add to Timeline.” This will send trigger notifications to a timeline, which will be created as a new table in your database after you’ve set up your trigger.
Under “Select field,” choose the fields for which you want your trigger to activate. These fields will then be sent to your timeline, as the field names that you define under “Timeline field.”
You may always select “Add Field” if there are additional fields you’d like to add to your timeline. When you’re finished, click “Apply.”
Note: After setting this up, nothing will initially happen. Only after updating the designated fields with a new action will the “Timeline” table be created, and then the system will send a notification to the timeline telling it what happened.
Schedule
The third kind of trigger is a schedule trigger. This will act as an alert which tells you in advance about a future event.
Name your trigger. Then, select a “Trigger Field” (note that the available fields are only those with date variables).
Under “Execute,” choose the number of hours before the scheduled event by when you would like to receive a notification. You can select “Add New Criteria” if, for example, you want to add that John should get a notification an hour before a meeting if he is the owner of the table.
Then, select “Add New Action” and choose how you want to receive the trigger. (You can see above for more information). After that, click “Apply,” and then click “Apply” again in the window that follows.
Congratulations! You have successfully set up your triggers.