Loading...

Approval processes are at the heart of many business workflows in Salesforce. Whether it’s an Opportunity, Quote, Order, or invoice, approvals determine how deals move forward.

But here’s the challenge – approval history is scattered across multiple related records.

This makes it difficult for users to:

  • Track who approved what 
  • Understand approval timelines 
  • View comments and decisions in context

To solve this, we built a centralized Approval History component that consolidates approval data from multiple related objects and displays it in one place using LWC and Apex.

What This Solution Does

This solution helps display:

  • Approver Name 
  • Assigned User 
  • Approval Status (Approved / Rejected / Recalled) 
  • Comments 
  • Approval Date 
  • Step Name

All of this is shown across multiple related objects in a single UI, improving visibility and decision-making.

Why We Built This

In real-world business scenarios, approvals don’t live in isolation.

For example:

  • An Invoice may relate to an Opportunity and Quote 
  • An Order may depend on multiple upstream approvals

Tracking approvals individually across these objects becomes:

  • Time-consuming 
  • Error-prone 
  • Inefficient for users

Our Approach

We created a reusable component that:

  • Aggregates approval history from related objects 
  • Displays them in structured tables 
  • Group them by object (Opportunity, Quote, Order, etc.)

Key Benefits

  • Centralized approval tracking 
  • Improved user efficiency 
  • Better audit visibility 
  • Reduced navigation effort

What We Used to Fetch Approval Details

To build this solution, we leveraged standard Salesforce approval objects and structured them efficiently.

1. Wrapper Class

We use a wrapper class to:

  • Store approval data from multiple objects 
  • Standardize fields like status, comments, approver, etc. 
  • Send structured data to LWC

2. ProcessInstance

This object helps us:

  • Fetch approval processes linked to records 
  • Identify approval status at a high level

3. ProcessInstanceStep

This is the core data source where we get:

  • Step Status (Approved, Rejected, etc.) 
  • Comments 
  • Actual Approver 
  • Assigned User 
  • Created Date

4. ProcessNode

Used to:

  • Retrieve the Step Name of the approval process 
  • Make the UI more meaningful for users

How It Works (High-Level Flow)

  1. We identify related records based on the current object 
  2. Fetch all ProcessInstance records 
  3. Retrieve detailed steps using ProcessInstanceStep 
  4. Map step names using ProcessNode 
  5. Store everything in a wrapper 
  6. Return structured data to LWC 
  7. Display it in grouped datatables.

Below is the code that includes LWC and Apex. Let’s check out:

JS. fetching data from Apex and sending it to the UI.

8. APEX: fetching details of approval on related objects using processInstance, ProcessInstanceStep, ProcessNode and storing them in a wrapper list.

Result:

If no approval exists on any related record, then the screen will look like this.

image 1

If approval history exists for related records, then it will look like this:

Image 2

Image 3

Conclusion

Managing approvals across multiple objects doesn’t have to be complicated. With this approach, we:

  • Eliminated the need to navigate across records 
  • Centralized approval tracking 
  • Improved user productivity and transparency

This scalable solution can be extended further to:

  • Include more objects 
  • Add filters or sorting 
  • Integrate with reporting dashboards

If your organization relies heavily on approval workflows, implementing a centralized approval history view like this can significantly streamline operations and enhance user experience.

No Data Found.

Related Articles
Our Location worldwide
Indian Flag India
3rd Floor, A-10, Pegasus Tower, Sector 68, Noida, Uttar Pradesh 201301 +91-1203239658
United States of America Flag USA
333 West Brown Deer Road Unit G – 366 Milwaukee WI, USA 53217 +1(262) 310-7818
United Kingdom Flag UK
7 Bell Yard, London, WC2A 2JR +44 20 3239 9428
Canada Canada
HIC Global Solutions INC
6D - 7398 Yonge St #1124 Thornhill, ON L4J 8J2 Canada +1(262) 310-7818