A custom path assistant built using only Lightning Web Components
Main reason for this project is that currently is not possible to replicate the same look and feel of the Opportunity Sales Path using custom Path Assistants. When you create a new Path Assistant you can specify an Object, a picklist field and a record type... What you miss is the ability to defines which picklist values are mutually exclusive at the end of the path.
We have a Project Object used to track the different implementation projects related to specified customers. Each Project record has a Status that can be:
- New
- In progress
- On hold
- Completed
- Failed
We want to display the Status as a path on the Project record page. We want the path to be green in case the status is Completed, red in case the status is Failed. If we create a Path Assistant and then add the standard Path Lightning component to the record page this is what we get:
Not really want we wanted! As you can see both values Completed and Failed are displayed. Even worst seems that Failed is the status that comes after Completed.
Without creating the Path Assistant we can instead use the custom Lightning Component called pathAssistant. In the Lightning App Builder drag and drop the custom component on the record page and fill the form on the right like this:
This is the result on the record page
Users can now select the final Closed status and after pressing on the button Select Closed Status they'll be able to select the proper value
Depending on the final status they pick these can be the results:
This Lightning Web Component is fully aware of its context when added to a Record page. This means that it's not object specific and can be added on any object that has a picklist field. It doesn't need to use an Apex controller thanks to the uiRecordApi module that provides method to update and retrieve records. In case your object has multiple record types the picklist values displayed are the one you enabled for it (same as standard Path Assistant). The only requirements this component has is that the picklist field, on which the path is based, has to be included in the Page Layout of the object.