database

Send data from an app

Updated: March 8, 2020

If you want to save data collected by your app, you must send it to a database. You can send all manner of data from an app to a database, including documents and analytics information (data regarding how often people use your app).

How to send data

Sending data from your app is a relatively simple two-step process:

Step 1. Add a Send Data function to a Page Block

You send data from a Page Block using the 'Send Data' function: 

When you add a 'Send Data' function, you must select where you want to send the data to. When you select 'Workbase', you'll be prompted to select which Workbase (you can have multiple) and which table within that Workbase.

You can only send data AFTER you collect it
You can only send data that has been defined in prior Page Blocks. You can't send data from the same Page Block where it is being collected.

Step 2. Specify what data you want to send

You decide exactly what data is sent to your database. When you click "+ Add", you can specify what column in your database you want to populate and what data you want to populate it with:

When you select what data you want to populate in the database column, you can either select a variable or type a value in directly.

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 in a Loop Section

You can add a 'Send Data' function within a Loop Section, which means every time the end-user repeats over the loop the app will add another row of data to your database.

There are two challenges when sending data from within a loop:

  1. From which Block inside the loop do you send data? 
  2. What do you use as the key value param?

From which Block inside the loop do you send data?

This is an issue because you can only send data that has been defined in prior Page Blocks (you can't send data from the same Page Block where it is being defined). This means you need to add a Page Block to your loop whose sole purpose is sending data collected in prior loop Page Blocks, like this:

The Info Block sends data collected in the prior Question Block

What do you use as the key value param?

You want the key value param to be unique for each loop member, otherwise every time the end-user repeats the loop they will re-write their own data. This means that your key value must be a variable defined within your loop (anything else will not be unique across loop members).

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:

Contact us for support

Talk to a real person, quickly. We're available 9am - 5pm EST.