Table of Contents

How To Number Line Items

Danielle Kellogg Updated by Danielle Kellogg

Scenario

There are a few scenarios where you may want line numbers to start over from "1" for a group of records. For example, in an Orders app, you have one or more Line Item records that are associated with a single Order record. For each new Order, any Line Items added will start at one and increment by a value of one for additional Line Items. The Line Item incrementation will start over from one for each new Order.

Requirements

If this your first time creating an app, you'll need to know some basics about adding objects, fields, pages, and views. You can start by reading our Builder Basics section

Other good resources can be found in our designing the database and building pages sections of the knowledge base.

This guide will use equations, formulas and record rules.

Steps

Add Objects & Fields

In the Schema section of your app, add a new object to your app called Orders.

Next, add a new object to your app called Line Items. Then, add a new number field to your Line Items object called "Item Number."

So now you will have two objects Orders and Line Items. The Line Items object will have a field called "Item Number"

Add Connections

Next, the Orders and Line Items objects need to be connected. Go to your Line Items object and add a connection field to Orders by clicking on the green "+" button in the Connections bar on the right side of the Builder.

Use the default one-to-many connection type. Each Order record will connect to many Line Items and each Line Item will connect to one Order.

Add Formulas & Equations

In your Orders object, add a count formula to count up the Line Item records connected to each Order record. Call this field "Line Item Count".

In your Orders object, add an equation field called "Current Count" that calculates “Line Item Count + 1”. This equation will use the Line Item Count field in the Orders object.

Add Pages

From the Pages section of the Builder, add a new page by clicking the green "+" button above the page list. Choose Orders as the source object and add the following views:

  • A table to display Orders
    • A details to view more Order fields.
    • A table to display Line Items connected to the Order.
    • A form to add a connected Line Item

Add Workflow

Go to the Order details page you just created in the last step and open the editor for the form view that adds a new Line Item. Click on the "Rules" tab and go to the “Record Rules” section.

Add a new record rule by clicking the "Add Rule" button and set the following values:

  • Action: update this record
  • When: every form submission
  • Value: Set Item Number to - a connected value - Current Count

Now your Line Item records will be numbered separately for each Order record.

How did we do?

How to Display Multiple Date Formats Using a Single Date Field

Show Upcoming Birthdays

Contact