The Revolution Blog
Generic filters
Exact matches only

Improving the Approval Process with JavaScript

Many companies that use Salesforce have invested in the platform as a way to automate processes throughout an organization. Throughout the workday, productivity and efficiency improve dramatically with automation.  In this blog, we’re going to discuss improving the approval process with JavaScript.

Within Salesforce, an approval process is defined as an automated process an organization can use to approve records in Salesforce.  An approval process specifies the steps necessary for a record to be approved, and who must approve it at each step.  A step can apply to all records included in the process, or just records that meet certain administrator-defined criteria.  An approval process also specifies the actions to take when a record is approved, rejected, recalled, or first submitted for approval.

For many using approval processes, it provides a way to automatically advance an approval to the next approver by updating one or more fields.  As requirements change, depending on status field, correctly submitting an approval process is key. Many Salesforce Administrators have noticed that if a dependent field is left blank, or filled in incorrectly, a generic “Unable to Submit” error page is displayed.

For many, this is seen as a speed bump in the approval process.  Every extra click to get an approval process through makes the automation less effective.

However, there is some good news! Although Salesforce is widely known as a “point and click” development tool, utilizing JavaScript can help to dramatically improve processes and efficiency on the back end.

By using JavaScript, Revolution Group was able to build a new Submit For Approval button that pre-screens fields on a page to ensure they meet the entry requirements of the approval process.  With the new button, if a field is blank or incorrect, it will be highlighted with a specific error message that helps users identify the problem quickly.

Improving the Approval Process with Java Script

The regular Submit For Approval button can be replaced as follows:

  1. Navigate to the object whose record is to be approved in the approval process. For example: Setup > Create > Objects > Project.
  1. Create a new Submit For Approval button with the following settings:

Display Type:           Detail Page Button

Behavior:                   Execute JavaScript

Content Source:       OnClick JavaScript

  1. Add JavaScript code for the button which confirms specific fields are filled prior to submitting the record for approval. Here’s an abridged example:

Java Script 1

Java Script 2


Note: the Salesforce DOM element IDs shown above can be gathered from the web page itself via your web browser’s development tools, or with a plug-in like Firebug.

4.  Edit the object’s page layout(s) where the new button is to be used. Remove the existing Submit For Approval button and replace it with the new one.

Improving the Approval Process with Java Script

5. Test the new button by intentionally leaving necessary approval fields blank, then confirming the error is displayed and the necessary approval fields are highlighted. Also confirm the approval process works properly when all of the necessary approval fields are filled.

As you build your Salesforce org to reflect what you want in a CRM solution, remember that hopping into the backend is an alternative way to make adjustments and customize your process leading to better automation, productivity and efficiency.

For more information on configuring your Salesforce org, please contact Revolution Group at 614-212-1111 or fill out the form below.