app builder

Using lists

Updated: June 8, 2021

A list is a collection of data, like this:

A list has "members", and each member has a number of "attributes". In the above example, the list has 3 members and each has the following attributes: name, date of birth, SSN, and location. Each attribute can be used as a variable.

There are two ways to create lists in Afterpattern: 

  1. Repeating questions (known as a loop); or
  2. Query Blocks which pull data into your App from a database.

This lesson covers everything after you create a list. Specifically, it covers how you can manipulate list data to create blocks of text (which can be added to documents) and perform calculations on list data.

How do I use variables from my list? 

The variables inside your list (e.g. `date of birth` in the above table) can't be used unless you first organize those variable with a List Block.

List Blocks are a type of Logic Block (click "+ Add Logic"): 

This very quick video illustrates why you can't use List variables without first organizing them with List Blocks (e.g. List Text, List Expression, etc):

List Text Blocks

List Text Blocks allow you to organize your List variables into a piece of text.

How it works: 

  1. Give your new variable a good name (e.g. 'children_as_text')
  2. Select the List you want to use
  3. Compose a piece of text that incorporates your List variables

Now, you can add your new variable ('children_as_text`) to a document template, and when that template is populated your piece of text will repeat X number of times, where X is equal to the number of members in your List (if your List is created with a Loop, then the number of members is equal to the number of times the end-user repeats over the Loop).

List Expression Blocks

List Expression Blocks allow you to use List variables in an Expression Editor (Expression Editors allow you to create logical rules).

This is how you perform all manner of logical expressions with the data in you lists. For example, imagine you have a Loop Section that collects the age of your end-user's children, like so:

You can use a List Expression Block to determine whether any children are less than 18 years old, like this:

Your List Expression variable ('any_minors') will be True or False depending on whether or not the end-user has any children whose age is less than 18.

Indexing into a List

So far, you have learned how to organize the data of all List members (with List Blocks and List Expressions). But what if you want to organize data for a specific List member? For example, what is the end-user creates a List of six children; how do you use the data of just the 2nd child? The answer is indexing.

Indexing means to pull out the data for a specific List member. To index into a List, all you need is an Expression Block:

Here is a very quick demonstration of how you can use indexing to pull data out of your list for a specific loop member: 

Sort Blocks

A Sort Block allows you to create a new list. This new list is a sorted version of a pre-existing list. The rule for sorting is created with a Expression Editor on the Sort Block:

List Selector Question

You can add the List Selector Question to any Question Block, just like any other question.

A List Selection Question allows you to provide the end-user with a dropdown where the items to choose from are members of a List. For example, if the end-user creates a List of their children, you can give them a dropdown of their children's names allowing them to select one:

Frequently Asked Questions

Don't see your question? Get support.

On this page

Hire an Afterpattern expert

Go from idea to launch in weeks.

View services