Send data from an app
By default, your Afterpattern apps do not save data. If you want to save the data your app collects, including documents and analytics information (how often people use your app), you must send it to a database.
Send data function
When you attach a send data function to a page block, your app will send data the moment that page is run.
You can attach a send data function to almost any page block, but the best practice is to use a background page:
You can send data to four different end points:
- Database: A table in your Afterpattern project's database. The remainder of this lesson will focus on this end point.
- Webhook: Allows you to send data to an open API on the internet. Learn more.
- Clio: The popular LPM system. Learn more.
- Google Sheets: A free cloud-based spreadsheet. Learn more.
Depending on which end point you select, you'll have to make a few more choices before moving onto part two, specifying what data you want to send. For example, if you send data to "Database", you'll have to choose which table to send data to.
How to specify what data you want to send
After you add a send data function to a page block, you must specify exactly data you want to send. To do that, click "Edit webhook" (the send data function is technically known as a webhook):
Edit webhook modal
After you click "Edit webhook", you can map data to your table columns. You add columns one at a time, and for each column you specify what data to send:
When you specify what data to send to a column, you can either select a variable from your app or write in a value:
What are "matching columns"?
You can auto send variable to matching columns, but what is a "matching column"? This requires careful planning when building your app. Learn more.
Sending key values
Remember, the left-most column in your database is the "key column." The value stored in this column must be unique for each row.
By default, when you send data from your app you are automatically assigning a random but unique value (a 32 character string):
You can choose anything to be your key column, just make sure that it's unique per user.
How to update existing rows
Whether your 'Send Data' function creates a new row or updates an existing row depends entirely on the value sent to the key column.
If you send data to a database and the key column value you send is equal to an existing key column value, the app will not create a new database record but instead will update that pre-existing record.
Sending data from a Loop Section
Send variables to matching columns
If your app's variables have the exact same name as a columns in your database, then the variables are "matching" and you can use this feature.
These variables match the database columns: