Quick Tutorial 13: Add Basic App Logic — Add A Formula Field

Another thing that's missing from the Line Item object is a Line Item Total field that displays the product of each Line Item's Quantity and Unit Price. In this tutorial, you implement this common business logic by creating a new formula field in the Line Item object, again, without writing any code.

Prerequisites

You must complete Quick Tutorial 1: Build a Cloud App in 5 Minutes before continuing with this tutorial.

Step 1: Create a Line Item Total Field

In this step, add a new custom field called Line Item Total to the Line Item object that automatically calculates field values from using a formula.

  1. Click <your_name> | Setup | Create | Objects.
  2. Click the Line Item object and in the Custom Fields and Relationships section, click New.
  3. Select Formula and click Next.
  4. For Field Label, enter Line Item Total
  5. For Formula Return Type, choose Currency and click Next.


Qs13 line item.png


  1. In the Formula editor, click the Insert Field drop-down list and choose Unit Price.
  2. For the Operator, choose Multiply.
  3. Click the Insert Field drop-down list again and choose Quantity.


Qs13 formula.png


Accept the defaults on the following screens by clicking Next until you can Save.

Step 2: Try Out the App

To see the new Line Item Total field in action, click the Invoices tab and click an existing invoice. You haven't added the new fields to the Invoice page layout (yet), but if you load a specific Line Item, notice there's now a Line Item Total and it's automatically populated.

Qs13 total.png

Next Steps