We have Sort button in OpportunityLineItem
. Using this, customer may able to sort the products in the order they want, but in Preview (Visualforce page preview) it's dispaying default order (Ascending by product name) not in the order customer sort. I used SortOrder in ORDER BY
but still I am not getting the order correctly. Here is my query in controller.
Oli= [Select
ID, OpportunityId, Description, Opportunity.Reactive_Sheet__c,
Opportunity.Service_Sheet__c, Service_Sheet__r.name, Maintenance_Reactive_Sheet__r.name,
Quantity, Product2.name, Maintenance_Reactive_Sheet__c, Service_Sheet__c,
Product2.Stock_Unit__c, UnitPrice, TotalPrice, Opportunity.VAT_Rate__c,
Service_Sheet__r.Visit__r.Asset__r.Name,
Show_Description__c, Line_Item_Description__c, Product2.Extended_Sales_Description__c,
Product2.Sales_Description__c
From OpportunityLineitem
Where OpportunityId =:Delnoteid
Order By SortOrder];
Delnoteid
= the current Opportunity Id.
I am using this controller in Visualforce component and surprisingly my Query runs twice .In first run Query returns default order (by product name).In second run query I have the correct order (in which the customer sort i.e the condition given in query works) but my page uses first time run query so it display default order instead of sort order.
OpportunityLineItem
records? If so, it would help if you were to edit your question to include the code for the Visualforce page as well. Also, where are you gettingSortOrder
from? If you want to allow people to sort by bothASC
(ascending) andDESC
(descending) orders, you'll probably need to move to dynamic SOQL. – Derek F May 15 '17 at 15:44