Skip to main content
Solved

Can we get record counting at processing pages?


Hello

Is it possible to enable record counting at Processing pages or Inquiry pages on Layout as it is at Generic Inquiries?

Best answer by Naveen Boga

Hi @NikaKakhetelidze  I have below the attached document to calculate the grid column totals based on the filters as well.

I’m hoping that this document will help you get the grid row count with the filters by tweaking the code.

 

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

11 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3417 replies
  • June 14, 2022

Hi @NikaKakhetelidze  Pages/Number of Records count will be shown in the native Acumatica.

For the Processing page, can you try like below and verify.

https://asiablog.acumatica.com/2018/07/page-number-on-acumatica-grid.html 

 

 


Dmitrii Naumov
Acumatica Moderator
Forum|alt.badge.img+7
  • Acumatica Moderator
  • 645 replies
  • June 14, 2022

To implement that you need 

  1. Have a View select Delegate for the view 
  2.        add the following code to the select delegate
    ​​​​​​​     if (PXView.RetrieveTotalRowCount)
                {
                    yield return new PXResult<...>(null)
                    {
                        RowCount = count
                    };
                }

     


Dmitrii Naumov wrote:

To implement that you need 

  1. Have a View select Delegate for the view 
  2.        add the following code to the select delegate
    ​​​​​​​     if (PXView.RetrieveTotalRowCount)
                {
                    yield return new PXResult<...>(null)
                    {
                        RowCount = count
                    };
                }

     

Hey thanks

protected virtual IEnumerable oRders()
        {
            if (PXView.RetrieveTotalRowCount)
            {
                yield return new PXResult<SOShipmentFilter>(null)
                {
                    RowCount = 
                };
            }
        }

How will this code work out?


Naveen Boga wrote:

Hi @NikaKakhetelidze  Pages/Number of Records count will be shown in the native Acumatica.

For the Processing page, can you try like below and verify.

https://asiablog.acumatica.com/2018/07/page-number-on-acumatica-grid.html 

 

 

this works for Custom Acumatica processing pages, I want to do this at Native Acumatica Processing Page


Forum|alt.badge.img+1
  • 99 replies
  • June 17, 2022
Naveen Boga wrote:

Hi @NikaKakhetelidze  Pages/Number of Records count will be shown in the native Acumatica.

For the Processing page, can you try like below and verify.

https://asiablog.acumatica.com/2018/07/page-number-on-acumatica-grid.html 

 

 

Naveen,
That article seems to refer mainly to page count. Any idea how to get the actual record count taking into account the UI filters?


@Dmitrii Naumov Hello and thank you for reply

 

I have tried the suggested code nd it did not seem to work (public virtual IEnumerable filter()

        {

            PXSelectBase cmd = GetShipmentsSelectCommand(Base.Filter.Current);

            PXSelectBase<SOShipment> pXSelectBase = cmd as PXSelectBase<SOShipment>;

            PXSelectBase<SOShipmentFilter> result = cmd as PXSelectBase<SOShipmentFilter>;

            int totalSelectedRows = 0;

            ApplyShipmentFilters(pXSelectBase, Base.Filter.Current);

            int startRow = PXView.StartRow;

            int totalRows = 0;

            if (pXSelectBase != null)

            {

                totalSelectedRows = pXSelectBase.View.Select(null, null, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters,

                    ref startRow, PXView.MaximumRows, ref totalRows).Count;

                Base.Filter.Current.GetExtension<SOShipmentFilter, SOShipmentFilterExt>().UsrRowCount = totalSelectedRows;

            }

 

            PXDelegateResult delegResult = new PXDelegateResult { };

 

            foreach (var item in result.SelectWithViewContext())

            {

                delegResult.Add(item);

            }

            return delegResult;

        }),

It was giving me error and after that I tried to add a new Field and put record count there.

So I further tried FieldSelecting Event with this logic:

protected virtual void SOShipmentFilter_UsrRowCount_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)

        {

            SOShipmentFilter row = (SOShipmentFilter)e.Row;

            if (row == null) return;

            PXSelectBase cmd = GetShipmentsSelectCommand(Base.Filter.Current);

            PXSelectBase<SOShipment> pXSelectBase = cmd as PXSelectBase<SOShipment>;

            PXView select = new PXView(Base, true, pXSelectBase.View.BqlSelect);

            int totalSelectedRows = 0;

            if (pXSelectBase != null)

            {

                ApplyShipmentFilters(pXSelectBase, Base.Filter.Current);

                int startRow = PXView.StartRow;

                int totalRows = 0;

                totalSelectedRows = select.Select(null, null, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters,

                    ref startRow, PXView.MaximumRows, ref totalRows).Count;

            }

            e.ReturnValue = totalSelectedRows;

        }

Here I want to count UI filtered records.


Even when I filter it gives whole amount

@Dmitrii Naumov


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3417 replies
  • Answer
  • June 17, 2022

Hi @NikaKakhetelidze  I have below the attached document to calculate the grid column totals based on the filters as well.

I’m hoping that this document will help you get the grid row count with the filters by tweaking the code.

 


Dmitrii Naumov
Acumatica Moderator
Forum|alt.badge.img+7
  • Acumatica Moderator
  • 645 replies
  • June 17, 2022

@NikaKakhetelidze to implement the record count in the select delegate you need to have two modes:

  1. Normal mode that just returns all the records 
  2. ‘Record Count’ mode

So, the full view select delegate code would look something like that:

public IEnumerable records()
{  
    if (PXView.RetrieveTotalRowCount)
    {
        int startRow = 0; 
        int totalRows = 0;

        PXSelect<SOShipment, Where<...>>.Select(null, null,
                               PXView.Searches,
                               Records.View.GetExternalSorts(),//Get sorting fields
                               Records.View.GetExternalDescendings(),//Get sorting direction
                               Records.View.GetExternalFilters(),//Get filters
                               ref startRow, 
                               PXView.MaximumRows, //Get count of records in the page
                               ref totalRows)();
        yield return new PXResult<...>(null)
            {
                RowCount = totalRows
            };
        }

        int startRow = 0; 
     else
     {
         foreach(var record in  PXSelect<SOShipment, Where<...>>.SelectWithViewContext())
         {
              yield return record;
         }
     }
}

 


Dmitrii Naumov wrote:

@NikaKakhetelidze to implement the record count in the select delegate you need to have two modes:

  1. Normal mode that just returns all the records 
  2. ‘Record Count’ mode

So, the full view select delegate code would look something like that:

public IEnumerable records()
{  
    if (PXView.RetrieveTotalRowCount)
    {
        int startRow = 0; 
        int totalRows = 0;

        PXSelect<SOShipment, Where<...>>.Select(null, null,
                               PXView.Searches,
                               Records.View.GetExternalSorts(),//Get sorting fields
                               Records.View.GetExternalDescendings(),//Get sorting direction
                               Records.View.GetExternalFilters(),//Get filters
                               ref startRow, 
                               PXView.MaximumRows, //Get count of records in the page
                               ref totalRows)();
        yield return new PXResult<...>(null)
            {
                RowCount = totalRows
            };
        }

        int startRow = 0; 
     else
     {
         foreach(var record in  PXSelect<SOShipment, Where<...>>.SelectWithViewContext())
         {
              yield return record;
         }
     }
}

 

@Dmitrii Naumov 

I just  tried this but if(View.RetrieveTotalRowCount) is always false...


Naveen Boga wrote:

Hi @NikaKakhetelidze  I have below the attached document to calculate the grid column totals based on the filters as well.

I’m hoping that this document will help you get the grid row count with the filters by tweaking the code.

 

//public virtual IEnumerable filter()
       {
            PXCache cache = Base.Caches[typeof(SOShipmentFilter)];
         SOShipmentFilter filter = cache.Current as SOShipmentFilter;
           var cmd = Orders.View.BqlSelect; //Add an aggregate function

           int startRow = 0;
           int totalRows = 0;
           var records = new PXView(Base, false, cmd)
               .Select(PXView.Currents, PXView.Parameters, PXView.Searches, Orders.View.GetExternalSorts(), Orders.View.GetExternalDescendings(),
                Orders.View.GetExternalFilters(), ref startRow, 0, ref totalRows);
           Base.Filter.Cache.Clear();
            filter.GetExtension<SOShipmentFilter, SOShipmentFilterExt>().UsrRowCount = totalRows;
            yield return cache.Current;
        }

-------------------------------------------------------------------------------------------

So at first I tried this approach and it was working but only after I was refreshing whole page, after that record was cached and new value appeard only after Reload page.

 

I decided to add Action button and when I click that Value assigned to field,

Mention that Orders View I have Copied in Extension class couse Orders.View.GetExternalFilters() was not working(it was null from Base.Orders)

------------------------------------------------------------------------------------------

[PXProtectedAccess]
    public abstract class SOInvoiceShipment_Extension : PXGraphExtension<PX.Objects.SO.SOInvoiceShipment>
    {
        [PXFilterable(new Type[]
        {

        })]
        public PXFilteredProcessing<SOShipment, SOShipmentFilter> Orders;

        [PXProtectedAccess]
        protected abstract PXSelectBase GetShipmentsSelectCommand(SOShipmentFilter filter);

        #region Actions
        public PXAction<SOShipmentFilter> Refresh;
        [PXUIField(DisplayName = "Refresh", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select, Enabled = false)]
        [PXButton(CommitChanges = true)]
        public virtual IEnumerable refresh(PXAdapter adapter)
        {
            var cmd = Orders.View.BqlSelect;

            int startRow = 0;
            int totalRows = 0;
            var records = new PXView(Base, false, cmd)
                .Select(PXView.Currents, PXView.Parameters, PXView.Searches, Orders.View.GetExternalSorts(), Orders.View.GetExternalDescendings(),
                Orders.View.GetExternalFilters(), ref startRow, 0, ref totalRows);
            Base.Filter.Current.GetExtension<SOShipmentFilter, SOShipmentFilterExt>().UsrRowCount = totalRows;
            Base.Filter.Update(Base.Filter.Current);
            return adapter.Get();
        }
        #endregion
    }


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