Filter cash accounts for next, prev.

Hello everybody.

Today I want to tell you a story how to make some special filtering in Accumatica. 

So at acumatica screen ScreenId=CA304000 which looks like this:

So my task was the following:

1. User permissions were configured in a way, that user shouldn't have permissions for some accounts for cases is user wants to enter new transaction.

2. If user press at buttons First, Previous, Next, Last he got opportunity to see documents for which he didn't have permissions.

In order to modify that functionality it was reuired to modify default behaviour.

In order to do this I used the following steps.

1. Analyzed which Data class is responsible for getting data in the page: CA304000. It was APInvoiceEntry.

2. In the source code of this class found which member takes recrods for the page CA304000, it was

public PXSelect<CAAdj, Where<CAAdj.draft, Equal<False>>> CAAdjRecords;

Then redeclared and overrided it in the following way:

public class CATranEntryExt : PXGraphExtension<CATranEntry>
    {
        public PXSelect<CAAdj, Where<CAAdj.draft, Equal<False>>> CAAdjRecords;

        protected virtual IEnumerable caadjrecords()
        { 
            var res = new List<CAAdj>();
            var availableCashAccounts = GetAvailableCashAccounts();
             foreach (
                var doc in
                    PXSelect<CAAdj, Where<CAAdj.draft, Equal<False>>>.Select(Base, new byte[0]))
            {
              // if for some reason you need this code, let me know via comments. For now I don't see practical value in it from Acumatica understanding view point.
             .
             .
             .
        }

Take note, that Acumatica uses convention over configuration principle. If you want to change functionality of some method, in our case CAAdjRecords, you can do it, via simply writing it from all non-capital characters.

Another important feature of acumatica is 

var res = new List<CAAdj>();
            var availableCashAccounts = GetAvailableCashAccounts();

            foreach (
                var doc in
                    PXSelect<CAAdj, Where<CAAdj.draft, Equal<False>>>.Select(Base, new byte[0]))
            {

In case if you want to get something from code of base class, you can use already mentioned >>>.Select(Base, new byte[0])) part and you'll achieve access to data in view ( which is also called PXSelect )

That's all for now. Enjoy your time

No Comments

Add a Comment