function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Sort Opportunity Product

Is there a way to automatically sort Opportunity Products?  By default, SFDC sorts Oppty product by name (alphabetically).  If i create a number field and populate each Pricebook Entry with the sort order number, can a trigger use that field to sort the Oppty products?   

If someone can share a code, i would greatly appreciate it.  This limitation is a pain in the butt. 
RamuRamu (Salesforce Developers) 
Hi, currently there is no standard feature that you can use to customize the sorting of products. The only way to do it is using visualforce page. The below discussion thread has some information on this

Below is the link to idea exchange post that you can vote to promote this idea
Dorothy Elaine Mangubat 8Dorothy Elaine Mangubat 8
Sorting by Product Name is now released by Salesforce (Winter '20) but users will have to move the products in to the order they want.

It doesn't sort automatically in one click. Still not helpful when you have 30+ products to sort.
The SortOrder field in the Opportunity Product and Quote Line Item objects is now updatable in Winter '20 release (API Version 47.0). I utilized this new updateable field access for the Quote Line Item Sorting in my apps, and the sorted Quote Line Items can now be populated onto a Quote PDF. Below is a video which shows how it works...

Sort Quote Line Items and Create PDF Made Easy in Salesforce

Sort Quote Line Items and Create PDF Made Easy in Salesforce