You need to sign in to do that
Don't have an account?
gary_t_jm
Quote Line Item Sort Order
My users order quote line items on quotes using the sort button on the related list.
When I query the quote line items using Apex, I'm not sure what field to use in my order by clause to reproduce the order they specifies using the sort button on the related list. Is there a way to re-produce the user specified sort order in Apex code?
SortOrder is in the system, despite not appearing in the Setup screen, or the Web Service's API Developer's Guide. It does appear in the WSDL under Develop > API, however. You can use it only if your API version is high enough (HINT: 16.0 is too low). Try changing your code's API to 23.0 or 24.0.
All Answers
Use the ORDER BY SortOrder ASC clause in your query. SortOrder is a (API) read-only field that defines the order of the line items.
Thank you for your reply. I tried adding the order by in a test query but received the following error:
Compile error at line 1 column 31
No such column 'SortOrder' on entity 'QuoteLineItem'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.
The test query I ran looks like this:
List<QuoteLineItem> qliList = [select Id from QuoteLineItem where QuoteId='0Q0Z0000000CgAy' order by SortOrder ASC];
When I look at the definition of the Quote Line Item object, I don't see the SortOrder field in the list of Standard Fields.
SFDC must somehow have this information though, because when I use the Sort button on the Quote Line Items related list, I'm able to rearrange the line order and the ordering I specify is persisted after I navigate away from the Quote page and then return.
Let me know if you have any thoughts about this, I'm considering opening a ticket with SFDC support.
SortOrder is in the system, despite not appearing in the Setup screen, or the Web Service's API Developer's Guide. It does appear in the WSDL under Develop > API, however. You can use it only if your API version is high enough (HINT: 16.0 is too low). Try changing your code's API to 23.0 or 24.0.
This worked!
I was at version 20 with my Eclipse IDE. After applying the update I'm now at version 24. I reran the query and it worked perfectly.
Thank you very much for your help!
Thank you, this worked perfectly :D
However I am not able to create a working controller for this