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 example app here: https://www.knack.com/purchase-orders-users-demo/
Define the Database
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:
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
1. Add a new Orders page, keeping the defaults to display records in a table and add new records with a form. Include options to view and add Line Item records connected to the Order:
2. Edit the Add 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: