# How to Build an Orders App

## In this tutorial, we will guide you through the necessary steps to create a basic orders app using Knack.

### Use Case

In this instructional guide, we will guide you through the process of creating an Orders app using Knack.

The main feature is using a form view's record rules to copy pricing information from products into order line items. Equations and formulas are used to track quantities and totals.

Tip: To take a look at one of our sample apps similar to this build, see our Purchase Orders app.

### Requirements

If this is your first time creating an app, you'll need to know some basics about adding tables, fields, pages, and views. You can start by reading our Builder Basics section.
Other good resources can be found in our About Your Database and Working With Pages article in our knowledge base.

### Steps

#### 1.  Define the Tables

First, we will add a Products table. This table will store all the details about each product that can be ordered, such as the Product #, Name, Price, Description, Images, etc:

Next, we'll add an Orders table. This table should contain details on the Order Date, Order #, and any other order information you'd like to track, such as the shipping information or any special instructions:

#### Line Items

Lastly, we'll add a Line Items table. We'll add an auto-increment field, delete the default short text field, and include additional fields for Quantity and Price:

For connections, we will connect the Line Items table to both the Products and Orders tables. Each "Line Items" record will connect to a single order record and a single product record.

#### 3.  Adding Equations and Formulas

Next, we will proceed with adding fields to accurately calculate the total cost of each line item and sum them up for each order.

In the Line Items table, we'll add a Total equation field to multiply the price by the quantity:

Tip:

Here are some additional articles for further learning on Equations:

In the Orders table, we will add a Sum formula to calculate the total cost of all connected line items. This formula instructs each order to locate any line items associated with that order and sum up their individual totals.

#### 4.  Building the Live App

To start creating the Live App pages, we'll add a new Orders page that displays a grid view of order records. Also, we'll add additional links to the following:

• Edit each record with a form

• A details page with:

• Details page of the Order

• Grid of connected Line Items

• Form to add a connected Line Item

On the new Order form, let's change the Submit Rule to redirect to the Order Details page. This way, as soon as the order is submitted, you can immediately start adding line item records:

#### 5.  Create a Record Rule for the Line Items Form

Lastly, we'll edit the Add Line Item form on the Order Details page. We'll delete the "Price" and "Total" inputs, and incorporate a record rule that establishes the value of the price as the price of the connected product.

By copying the price value, this price will be permanently saved. Even if you were to update the product's price in the future, the price for this line item will remain unchanged.

Congratulations on successfully building your Orders app! That completes the app building walk-through.

### Extending the App

This is the fundamental functionality required for a basic order app: the ability to add Products to an Order through a Line Item record that connects them.

It is possible to further enhance this app by incorporating additional features:

• Add pages to the live app to manage the products.