Hi everyone,
I added a custom boolean field, say "myField", to the DAC ARDocumentRelease.ARInvoice in an extended DAC (ARInvoiceExt). Now, I need to customize in a graph extension the view "ARDocumentList" from the graph "ARDocumentRelease" so that it provides only the records (among the ones it natively returns) for which "myField" is not true.
The problem is that this view has a delegate in the Acumatica ARDocumentRelease graph.
I had overriden this delegate in my graph extension like this :
public delegate IEnumerable ArdocumentlistDelegate();
[PXOverride]
public IEnumerable ardocumentlist(ArdocumentlistDelegate baseMethod)
{
var list = baseMethod();
return list.Cast<PXResult<BalancedARDocument, ARDocumentRelease.ARInvoice, ARDocumentRelease.ARPayment, Customer, ARAdjust>>()
.Where(it => true != it.GetItem<ARDocumentRelease.ARInvoice>().GetExtension<ARInvoiceExt>()?.myField);
}
This works quite fine but there is a perverse effect to this solution.
When the screen opens, for performence reason, it doesn't requests all the records corresponding to the view but only the N first ones depending on the space available in the grid.
Let's suppose that 100 records correspond to the view and that the grid can contain 15 records and, that, as a result, the view requires the 20 first records.
If, for instance, 11 of these first records are skipped by my custom delegate, there are only 9 records remaining for display.
The other records (after the 20th first ones) are not displayed and the button allowing to go to next page is disabled.
Conclusion
We should not filter records in a view delegate in such cases.
Question
In a graph extension, are there any other solutions to add selection criterias in a base view that has delegate ?