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)
- We identify related records based on the current object
- Fetch all ProcessInstance records
- Retrieve detailed steps using ProcessInstanceStep
- Map step names using ProcessNode
- Store everything in a wrapper
- Return structured data to LWC
- 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.
If approval history exists for related records, then it will look like this:
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.