today I want to share with you very important and I'd say interesting use case of Acumatica views and delegates.
As you may know, Acumatica views have precedence in sorting of results over Acumatica view delegates overloading.
It means that if your View has sorting by Column1, and view delegate has sorting by Column2, then final result will be sorted by Column1 disregarding of results of reading in delegate override.
How to do with cases if you have requirement to sort by column2 in your view delegate? You can achieve that with combination of PXDelegateResult and SelectViewWithContext. Full code sample is shown below:
public class SomeGraph : PXGraph<SomeGraph>
private PXSelect<BalancedARDocument> Ardocumentlist;
protected virtual IEnumerable ardocumentlist()
PXSelectBase<BalancedARDocument> cmd =
PXDelegateResult delegResult = new PXDelegateResult
IsResultFiltered = true,
IsResultTruncated = true,
IsResultSorted = true
foreach (PXResult<BalancedARDocument> resRecord in
// add the code to process res_record
Another facet, which is achieved by such combination is amount of data, which will be read from database. SelectWithViewContext will read one page of data instead of whole data set in comparison with PXSelect or SelectFrom
If you need to have your sorting with limited reading from database, then SelectWithViewContext + PXDelegateResult is combination, which you may definitely need in your toolbelt. Use it for your own benefit.