Skip to main content
Solved

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


Forum|alt.badge.img+1

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 ?

Best answer by Leonardo Justiniano

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.

 

View original
Did this topic help you find an answer to your question?

2 replies

Leonardo Justiniano
Jr Varsity II
Forum|alt.badge.img+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.

 


Forum|alt.badge.img+1
  • Author
  • Varsity II
  • 46 replies
  • April 8, 2024

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings