Table of Contents

Build an Orders App

Danielle Kellogg 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:

You can read more about adding and managing objects here.

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:

You can read more about adding connections here.

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:

You can read more about using equation fields here.

​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:

You can read more about using formula fields here.

Build the Live App

1. Add a new Orders page, that displays a table of order records. Also add additional links to:

  • 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

2. Add an Add Order form on your new Orders page by first adding a new menu view that links to a new page. Then on that new page, add a form that adds a new Order record.

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.

You can easily extend this app to add additional features:

  • Add pages to the live app to manage the products.
  • Add ​user logins​​ and track which user added the order.
  • Connect each product to a vendor object.
  • Add ​reports​​ to view order totals by product, vendor, or user.
  • Add a status field to orders and include workflow to track shipping and fulfillment.

How did we do?

Build a Member Directory

Build a Map Directory or Store Locator App

Contact