Pulling data into your App is how you allow the end-user to "look up" information in your database. The most common use-case for pulling data into an App is using previously collected data to quickly populate a document template.
Pulling data into your App is a two-step process:
There are four methods for accomplishing step 2 (detailed below), but regardless of the method you choose the end result is the same: you create variables inside your App for each column in your Workbase table.
Any data that you want to pull into your App must be added as a Data Source under the Data Source tab of the App Builder:
Each data source is represented in your App as a variable. As always, it's a good idea to rename the variable's label to something that makes sense in context (e.g. "client_data"):
That's it for Step 1. Next, you need to specify how you want your App to "look up" a row of data in this Data Source.
When you add a database as a data source to your app, you have access to every row inside your database table. But how does the app know which row you want to use? Imagine your table contains client data: how does the app know which client to pull data about?
There are four methods for determining how your app will "look up" a row of data from your database:
Method 1: Row selector question: Provide the end-user with a search field with which they can "look up" a specific row of data (note: the end-user can only search through the key column of your table).
Method 2: Add app to database toolbar: Add the App to your database toolbar and you'll be able to look at your database table, click on a row, and use that row inside your app.
Method 3: Index into the database: Use a variable to "look up" a row from your database table. This variable can be defined by asking the end-user a question (e.g. "what is the client's name?").
Method 4: Query block: The most powerful method of finding a row. Allows end-user to "look up" a row using any column from the Data Source table.
Use this method to allow the end-user of your App to find for a specific row in your Workbase by searching through the key column of your table.
This is what a Row selector question looks like when you run your app:
(1) Add a 'row selector' question to a question block; (2) select the data source you want to attach this question to; and (3) be sure to give your 'row selector' question variable a useful name.
Now, you have available inside your app a variable for each column in your database table. These new variables look like this:
Notice that these new variables combine your row selector question variable with the name of the columns in your database.
You can add apps directly to the header of your database, known as the database toolbar:
Adding Apps to your database toolbar allows you to "look up" a row of data by simply clicking on that row and then selecting the app you want to use that data in.
This method is only appropriate if you want to give the end-user access to your database table (note: you can give end-users access to only some of your database data with portals and database connections).
Click the 'Add app to database toolbar' toggle.
That's it; you now have variables inside your app for each column inside your database table. Note: you must activate your app in order to see it in the database toolbar.
You can use a variable to search through your Workbase for a matching row of data. You can only search through the database table's key column.
Indexing is accomplished with an Expression Block: (1) Add an Expression Block and select your database variable as the first component; (2) select 'index' as the operator; then (3) add the variable with which you want to search through the database table key column:
The variable you are using to index through the database table's key column can be supplied from many places, including:
By far the most flexible and powerful method for "looking up" a row in your database table. A Query Block lets you "look up" a row in your database by searching through any column in your database table (whereas most other methods only allow you to search through the key column of your table).