Solved

How to add selection criterias to a view that has a delegate

  • 5 April 2024
  • 2 replies
  • 30 views

Userlevel 3
Badge

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 ?

icon

Best answer by Leonardo Justiniano 5 April 2024, 17:01

View original

2 replies

Userlevel 6
Badge +4

Hi @ygagnaire12 

Override the view delegate and modify the internal BQL by adding your condition. This imply you have to basically copy the original method and adjust it with your logic, and not invoking the base method (I do not like this but sometimes there is no options)

PS: Acumatica have other graphs where those BQL are in a separated method that you can override making the task a way more simple as they realized about this specific issue.

 

Userlevel 3
Badge

Hi @Leonardo Justiniano,

Thank you for this suggestion.You're right, it is indeed a way of solving my problem but, like you, I try to avoid this kind of approach as much as possible: it generates vulnerabilities in the code of our projects, When Acumatica changes its code indeed, we have to be aware of it and change ours too.

So, in this particular case, I was hoping that there was a solution that I hadn't seen, but that's probably not the case. I will use the way you suggested.

 

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved