You need to sign in to do that
Don't have an account?
SOQL - OpportunityLineItem Sort
I have some apex code that queries the opportunity and opportunitylineitem tables orders by sortorder and then sends an xml off to a back office ERP system to create a sales order. My users want the order of the lines on the sales order to appear in the same order as the opportunity lines on the opportunity. Ordering the query results by sortorder works when a user has specified a specific order for the products, otherwise it doesn't work because sortorder is null. What would the best way to get around this? Check to see if sortorder is null then us the list.sort function to sort the list by product name? Any ideas would be appreciated, thanks!
That's how sfdc does it, and that's how'd you do it if you wanted to mimic that behavior.