# Build an Orders App

Updated by Danielle Kellogg

### Scenario

This article walks you through using Knack to create an Orders app.

The main feature is using a form's Record Rules to copy pricing information from products into order line-items. Equations and Formulas are used to track quantities and totals.

You can see the Orders example app here.

### 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.

### Steps

#### Define the Objects

1. Add a Products object. This stores all the details about each product that can be ordered, like the Product #, Name, Price, Description, images, etc:

​2. Add an Orders​ object. It should contain details on the Order Date, Order #, and any other order information you'd like to track like the shipping info or any special instructions:

#### Line Items

1. Add a Line Items object. Change the first field to an auto increment field and add additional fields for Quantity and Price:

2. Connect Line Items to both the Products and Orders objects.  Each Line Item records will connect to a single order record and a single product record:

#### Equations and Formulas

Add fields to track the total cost of each line item and add those up for each order.

1. In the Line Items object, add a Total equation field to multiply the price by the quantity:

​2. In the Orders object, add a Sum​ formula for adding up the connected line item totals. This tells each order to find any line items connected to that order and add up the line item totals:

#### Build the Live App

• Edit each record with a form
• A details page with:
• Details page of the Order
• Table of connected Line Items
• Form to add connected Line Items

On that new Order form, 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:

​3. Edit the Add Line Item​ form on the Order Details page. Delete the Price and Total inputs, and add a record rule to set the value of the Price to the connected product's price.​

​By copying the price value this price will be "frozen" in history.  Even if you change the product's price in the future, this price will stay locked for this line item:

### Extend the App

This is the core functionality needed for a basic order app: adding Products to an Order through a Line Item record that connects to both.

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