
Usually by the third time I see a question asked, I realize it needs to be a blog post. I’ve been asked by a couple of customers how to add a default sort to the products list on the Add Opportunity Products form in the SalesLogix Web client. The question of how to add a default sort to the list of products in the Add Opportunity Products form in the web client surfaced again today so I am posting the answer here.
The approach to sorting the products list on the Add Opportunity products form is different than what I have outlined before for simply sorting a grid. The opportunity products list is not a DataGrid, but a Tree control.
To sort the products list, instead of telling the control to sort, we will just sort the list of objects that it is bound to.
First, locate the AddOpportunityProduct SmartMart. This is a custom SmartPart, not a QuickForm, so you won’t find this under the Opportunity entity itself, but instead in the Sage SalesLogix Portal in following location (we’ll just need the code-behind, or “cs” file for this, not the “ascx” file):
Support FilesSmartPartsOpportunityAddOpportunityProduct.ascx.cs
Double-click that file to open it in the Application Architect. In the code, look for the method named GetProductList. You’ll see the following two lines at the very end of that method:
List<Product> ProductList = criteriaProduct.List<Product>() as List<Product>; return ProductList; |
Right before those two lines, add the following line (in this case, we’ll sort the list by family):
criteriaProduct.AddOrder(expProduct.Asc("Family"));
|
Obviously, you can replace “Family” with any other valid property name on the Opportunity entity to sort the results by.
Ryan, this seems to have changed with v8. Can you suggest a method for doing this in v8?