Skip to main content
Solved

Need help overriding the getAPDocumentSelect method on the APApproveBills graph

  • 22 July 2024
  • 4 replies
  • 25 views

I added a custom field UsrHoldForPaymentProcess to the Bills and Adjustments screen.  This field gets created in the APRegister table.  It is a checkbox to indicate that we do not want to show this bill on the Approve Bills for Payment screen.

 

On the Approve Bills for Payment screen, I want to only show Bills that do not have the UsrHoldForPaymentProcess field set to true.

One problem I see is that the select statement for the Approve Bills screen pulls from APInvoice, not APRegister.

 

To adjust what gets displayed in the grid, I want to override this method in the APApproveBills graph

private static Type getAPDocumentSelect(bool groupBy = false)
 

I cannot seem to get the override correct as I get an error that the signature does not match.

public delegate Type getAPDocumentSelectDelegate(bool groupBy = false);
ePXOverride]
public static Type getAPDocumentSelect(bool groupBy, getAPDocumentSelectDelegate baseMethod)
 

 

I tried to do what would seem like the EASY approach by adding a Where to the View in the initialize, but it does not have any impact.

Since the APDocumentList view uses the APInvoice table for the select, for testing, I created another extension field in the APInvoice table with the same Usr field name as in the APRegister table.  In SQL, I updated one record so that the field is set to true.  But the bill still shows in the grid.

public override void Initialize()
{
    this.Base.APDocumentList.WhereAnd<Where<TenFedAPInvoiceExt.usrHoldForPaymentProcess, IsNull, Or<TenFedAPInvoiceExt.usrHoldForPaymentProcess, Equal<boolFalse>>>>();
}
 

I think if I can get the signature figured out, I can do the join from APInvoice to APRegister and restrict the returned query to remove the records where my Usr field is true.  It means copying a lot of Acumatica lines and making a couple tweaks, but I think that would work.

Help!  :-)

4 replies

Badge +12

Unfortunately, you can’t override static methods with [PXOverride]

Userlevel 7
Badge +3

Thanks @darylbowman .  That is good to know, but bad for the customer.  

I don’t think I can do what they are asking.  If I can’t modify the PXView used for the grid, then I can’t change the results in the grid.

I will let them know that this is not an option for them.

Userlevel 6
Badge +2

Hi @Joe Schmucker 

While you can’t override the getAPDocumentSelect, you can override the apdocumentlist() data handler. It will require a lot of copy-paste just to replace getAPDocumentSelect call with your modified query, but it should get the job done.

Userlevel 7
Badge +3

@andriitkachenko , That is also good to know.  You are right that it would be a lot of duplicating Acumatica’s code.  In this case, it is not a “show stopper” for the customer.  Instead of modifying the filter on the screen, I just added the Usr field to the grid and they can use filters to hide the on hold records.

I appreciate the idea.  If it was really badly needed, I’d do it.

Reply