Quick Tutorial 15: Add Basic App Logic — Create an Approval Process

Right now, the Warehouse app lets users modify data as necessary, however they see fit. However, in many cases, business dictates that certain flows happen. One of the best examples of this is an approval process — when someone needs to approve a change to a record before the change is final.

In this tutorial, you learn how to implement a common approval process scenario in the Warehouse app. The approval process requires that, when a user changes the default Unit Price in a Line Item, the user submits the change for approval, after which a manager must approve or reject the change.

Prerequisites

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

Step 1: Create an Approval Process

To create an approval process, start in the familiar Setup area by clicking <your_name> | Setup | Create | Workflow & Approvals and choose Create New Approval Process. Then choose the Line Item object and then select Use Jump Start Wizard.


Qs15 jumpstart.png

Configure the approval process basics as follows:

  1. In the Name field, enter Approve Unit Price Change.
  2. Make sure the checkbox labeled Add the Approval History related list to all Line Item page layouts is selected.
  3. Click the drop-down list next to Use this approval process if the following and choose formula evaluates to true.
  4. In the formula field, click Insert Field , select Line Item > and then select Unit Price. Click Insert.
  5. Click Insert Operator and select <> Not Equal.
  6. Click Insert Field , select Line Item >, select Merchandise > and then Price. Click Insert.

Before moving on, make sure your screen looks like the following:


Qs15 merch price.png


Now you need to assign the approval to someone. For large companies where multiple people could have the ability to grant approval, you might assign this to a queue. In your org, there's only one user (yourself), so click the option for Automatically assign to approvers and choose yourself. Then select Approve or reject based on the FIRST response.


Qs15 approver.png


Save your work, click OK in the pop-up, and then click View Approval Process Detail Page.

Step 2: Examine the Approval Process Detail Page

The detail page of the approval process has a lot going on, and it's worth a minute to explore the following image:


Qs15 detail page.png


On the detail page you can:

  1. Edit every step of an approval process.
  2. Create or delete an approval process.
  3. Activate and deactivate an approval process.
  4. View an approval process diagram as a flow chart.
  5. View general details of the approval process.

In addition, you can add new steps and actions (email alerts, field updates, and outbound messages) wherever you want.

Step 3: Modify Approval Process Actions

In this step you modify the approval process so that if the price change is rejected, the price resets to the default merchandise price.

  1. Scroll down to Final Approval Actions and click the Edit link next to Record Lock.
  2. Chose Unlock the record for editing and then Save.
  3. In the Final Rejection Actions section, click Add New > Field Update.
  4. In the Name field, enter Reset Price
  5. In Field to Update, choose Unit Price.
  6. Select Use a formula to set the new value.
  7. Click Show Formula Editor.
  8. Use the Formula Editor to specify Merchandise__r.Price__c and then Save.

Step 4: Activate the Approval Process

Before you can use the approval process, you need to activate it. This might seem like an unnecessary step until you think about situations where you might not want an approval process to run. For example, let's say you want to run a special promotion and decrease the price of a certain laptop in all open invoices. This would fire off the approval process for every open invoice, creating a bottleneck to getting orders out the door. In a case like this, you'd want to deactivate the approval process before running the batch update. When you're finished, you'd active the approval process again.

  1. Navigate to the detail page of the approval process.
  2. Click Activate and then click OK in the pop-up.

Step 5: Try Out the App

Now it's time to try out the new approval process and simulate the workflow as both the submitter and approver of a change.

  1. Click the Invoices tab, click an invoice, and then add a new line item to the invoice.
  2. Edit the new line item, change Unit Price and then click Save.
  3. Click Submit for Approval.
  4. Notice the record is unlocked.
  5. Notice you get a default email.
  6. Notice, in approval history, the status is Pending.
  7. You could approve from here, but instead click the Home tab and scroll down to see this addition to the Home page dashboard.
  8. Click Approve/Reject.
  9. Add a comment, then click Approve.
  10. Notice the record is unlocked and the Status is Approved.
  11. Repeat the process, but reject it.
  12. Notice that unit price reverts to the default merchandise price.

Step 6: Configure Email Approvals

Approval processes have built-in support for email, so approvers can approve or reject approvals directly from their email.

  1. In the App Setup area, click Create > Workflow & Approvals.
  2. Click Settings and select Enable Email Approval Response. Click Save.
  3. As you did before, choose an invoice, click a line item, and modify the price.
  4. Submit the price change, and then check your email.
  5. Reply to the email and on the first line of the email body, type REJECT
  6. On the second line of the email body, leave a comment by typing Too low, please adjust.
  7. Send the email.
  8. Now refresh the Line Item page, and you'll see both the rejected approval, as well as the comment.

Congratulations. This is a fairly complex piece of app logic that you implemented without any code.

Next Steps