最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

acumatica - Automatically Press Select All Based on Selector Filter Value - Stack Overflow

programmeradmin2浏览0评论

Hi I have created 2 selectors in material wizard 1 screen (AM300010) as below

[PXDBString(100)]
[PXSelector(typeof(Search<AMProdItem.prodOrdID>),
            typeof(AMProdItem.prodOrdID),
            typeof(AMProdItem.orderType),
            typeof(AMProdItem.inventoryID),
            typeof(AMProdItem.prodDate),
            SubstituteKey = typeof(AMProdItem.prodOrdID),
            DescriptionField = typeof(AMProdItem.descr))]
[PXUIField(DisplayName="Production Nbr.")]

[PXInt]
[PXDefault(typeof(Search<UserPreferenceExt.defaultSite,
    Where<UserPreferences.userID, Equal<Current<AccessInfo.userID>>>>),
    PersistingCheck = PXPersistingCheck.Nothing)]
[PXSelector(
            typeof(Search<INSite.siteID>),
            typeof(INSite.siteCD),
            typeof(INSite.descr),
            SubstituteKey = typeof(INSite.siteCD))]
[PXUIField(DisplayName="Warehouse")]

If the selector gives one record after putting the production number in the filter it should automatically press the Select All button.

How can I achieve this, I have tried using Base.Actions["ProcessAll"].Press(); but i get the error:

Insufficient stack to continue executing the program safely. This can happen from having too many functions on the call stack or function on the stack using too much stack space.

using System;
using PX.Data;
using System.Collections.Generic;
using PX.Objects.CS;
using System.Collections;
using System.Linq;
using PX.Objects.IN;
using PX.Objects.AM.Attributes;
using PX.Objects;
using PX.Objects.AM;

namespace PX.Objects.AM
{
  public class MatlWizard1_Extension : PXGraphExtension<PX.Objects.AM.MatlWizard1>
  {
    #region Event Handlers
  
  

    protected void AMProdItem_Selected_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated baseHandler)
    {
     
baseHandler?.Invoke(cache, e);
            var row = (AMProdItem)e.Row;
             if (row.Selected == true) // Only if the item is selected
        {
            //row.QtytoProd = 1.0000m;
          //cache.Update(row);
          cache.SetValueExt<AMProdItem.qtytoProd>(row, 1.0000m); // Notify Acumatica of the update
        }
      
    }

     #endregion

#region View Extensions
   protected virtual IEnumerable openOrders()
        {
          
          
            var baseView = new PXView(Base, true, Base.OpenOrders.View.BqlSelect);
            var startRow = PXView.StartRow;
            int totalRows = 0;
            var filter = Base.filter.Current;
            
            if (filter == null)
            {
                return baseView.Select(PXView.Currents, PXView.Parameters,
                    PXView.Searches, PXView.SortColumns, PXView.Descendings,
                    PXView.Filters, ref startRow, PXView.MaximumRows, ref totalRows);
            }

            var filterExt = filter.GetExtension<WizFilterExt>();
            
            // If neither filter is set, return base view
            if (filterExt?.UsrWarehouseSelector2 == null &&
                string.IsNullOrWhiteSpace(filterExt?.UsrProdOrderNoFilter))
            {
                return baseView.Select(PXView.Currents, PXView.Parameters,
                    PXView.Searches, PXView.SortColumns, PXView.Descendings,
                    PXView.Filters, ref startRow, PXView.MaximumRows, ref totalRows);
            }

            // Build the where clause based on active filters
            BqlCommand cmd = new Select<AMProdItem>();
            
            // Base conditions
            cmd = cmd.WhereAnd<Where<AMProdItem.function, NotEqual<OrderTypeFunction.disassemble>,
                And<Where<AMProdItem.isOpen, Equal<True>,
                And<AMProdItempleted, NotEqual<True>>>>>>();

            // Add warehouse filter if specified
            if (filterExt?.UsrWarehouseSelector2 != null)
            {
                cmd = cmd.WhereAnd<Where<AMProdItem.siteID, Equal<Required<AMProdItem.siteID>>>>();
            }

            // Add production number filter if specified
            if (!string.IsNullOrWhiteSpace(filterExt?.UsrProdOrderNoFilter))
            {
                cmd = cmd.WhereAnd<Where<AMProdItem.prodOrdID, Like<Required<AMProdItem.prodOrdID>>>>();
            }

            var view = new PXView(Base, true, cmd);
            var parameters = new List<object>();

            // Add parameter values in the same order as the where conditions
            if (filterExt?.UsrWarehouseSelector2 != null)
            {
               parameters.Add(filterExt.UsrWarehouseSelector2);
            }
            if (!string.IsNullOrWhiteSpace(filterExt?.UsrProdOrderNoFilter))
            {
                parameters.Add("%" + filterExt.UsrProdOrderNoFilter + "%");
            }

            return view.Select(PXView.Currents, parameters.ToArray(),
                PXView.Searches, PXView.SortColumns, PXView.Descendings,
                PXView.Filters, ref startRow, PXView.MaximumRows, ref totalRows);
             
             // var result = view.Select(PXView.Currents, parameters.ToArray(),
              //  PXView.Searches, PXView.SortColumns, PXView.Descendings,
              //  PXView.Filters, ref startRow, PXView.MaximumRows, ref totalRows);
              
                // If only one record is returned, ensure it's selected
                    //if (result.Count == 1)
            //{
           //    Base.Actions["ProcessAll"].Press();
           // }
     
            //return result;
              
        }
      

    #endregion
  }
}

Please let me know how I can achieve my filtration logic as well as automatically execute the Select All action once 1 record is filtered, thank you!

Hi I have created 2 selectors in material wizard 1 screen (AM300010) as below

[PXDBString(100)]
[PXSelector(typeof(Search<AMProdItem.prodOrdID>),
            typeof(AMProdItem.prodOrdID),
            typeof(AMProdItem.orderType),
            typeof(AMProdItem.inventoryID),
            typeof(AMProdItem.prodDate),
            SubstituteKey = typeof(AMProdItem.prodOrdID),
            DescriptionField = typeof(AMProdItem.descr))]
[PXUIField(DisplayName="Production Nbr.")]

[PXInt]
[PXDefault(typeof(Search<UserPreferenceExt.defaultSite,
    Where<UserPreferences.userID, Equal<Current<AccessInfo.userID>>>>),
    PersistingCheck = PXPersistingCheck.Nothing)]
[PXSelector(
            typeof(Search<INSite.siteID>),
            typeof(INSite.siteCD),
            typeof(INSite.descr),
            SubstituteKey = typeof(INSite.siteCD))]
[PXUIField(DisplayName="Warehouse")]

If the selector gives one record after putting the production number in the filter it should automatically press the Select All button.

How can I achieve this, I have tried using Base.Actions["ProcessAll"].Press(); but i get the error:

Insufficient stack to continue executing the program safely. This can happen from having too many functions on the call stack or function on the stack using too much stack space.

using System;
using PX.Data;
using System.Collections.Generic;
using PX.Objects.CS;
using System.Collections;
using System.Linq;
using PX.Objects.IN;
using PX.Objects.AM.Attributes;
using PX.Objects;
using PX.Objects.AM;

namespace PX.Objects.AM
{
  public class MatlWizard1_Extension : PXGraphExtension<PX.Objects.AM.MatlWizard1>
  {
    #region Event Handlers
  
  

    protected void AMProdItem_Selected_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated baseHandler)
    {
     
baseHandler?.Invoke(cache, e);
            var row = (AMProdItem)e.Row;
             if (row.Selected == true) // Only if the item is selected
        {
            //row.QtytoProd = 1.0000m;
          //cache.Update(row);
          cache.SetValueExt<AMProdItem.qtytoProd>(row, 1.0000m); // Notify Acumatica of the update
        }
      
    }

     #endregion

#region View Extensions
   protected virtual IEnumerable openOrders()
        {
          
          
            var baseView = new PXView(Base, true, Base.OpenOrders.View.BqlSelect);
            var startRow = PXView.StartRow;
            int totalRows = 0;
            var filter = Base.filter.Current;
            
            if (filter == null)
            {
                return baseView.Select(PXView.Currents, PXView.Parameters,
                    PXView.Searches, PXView.SortColumns, PXView.Descendings,
                    PXView.Filters, ref startRow, PXView.MaximumRows, ref totalRows);
            }

            var filterExt = filter.GetExtension<WizFilterExt>();
            
            // If neither filter is set, return base view
            if (filterExt?.UsrWarehouseSelector2 == null &&
                string.IsNullOrWhiteSpace(filterExt?.UsrProdOrderNoFilter))
            {
                return baseView.Select(PXView.Currents, PXView.Parameters,
                    PXView.Searches, PXView.SortColumns, PXView.Descendings,
                    PXView.Filters, ref startRow, PXView.MaximumRows, ref totalRows);
            }

            // Build the where clause based on active filters
            BqlCommand cmd = new Select<AMProdItem>();
            
            // Base conditions
            cmd = cmd.WhereAnd<Where<AMProdItem.function, NotEqual<OrderTypeFunction.disassemble>,
                And<Where<AMProdItem.isOpen, Equal<True>,
                And<AMProdItem.completed, NotEqual<True>>>>>>();

            // Add warehouse filter if specified
            if (filterExt?.UsrWarehouseSelector2 != null)
            {
                cmd = cmd.WhereAnd<Where<AMProdItem.siteID, Equal<Required<AMProdItem.siteID>>>>();
            }

            // Add production number filter if specified
            if (!string.IsNullOrWhiteSpace(filterExt?.UsrProdOrderNoFilter))
            {
                cmd = cmd.WhereAnd<Where<AMProdItem.prodOrdID, Like<Required<AMProdItem.prodOrdID>>>>();
            }

            var view = new PXView(Base, true, cmd);
            var parameters = new List<object>();

            // Add parameter values in the same order as the where conditions
            if (filterExt?.UsrWarehouseSelector2 != null)
            {
               parameters.Add(filterExt.UsrWarehouseSelector2);
            }
            if (!string.IsNullOrWhiteSpace(filterExt?.UsrProdOrderNoFilter))
            {
                parameters.Add("%" + filterExt.UsrProdOrderNoFilter + "%");
            }

            return view.Select(PXView.Currents, parameters.ToArray(),
                PXView.Searches, PXView.SortColumns, PXView.Descendings,
                PXView.Filters, ref startRow, PXView.MaximumRows, ref totalRows);
             
             // var result = view.Select(PXView.Currents, parameters.ToArray(),
              //  PXView.Searches, PXView.SortColumns, PXView.Descendings,
              //  PXView.Filters, ref startRow, PXView.MaximumRows, ref totalRows);
              
                // If only one record is returned, ensure it's selected
                    //if (result.Count == 1)
            //{
           //    Base.Actions["ProcessAll"].Press();
           // }
     
            //return result;
              
        }
      

    #endregion
  }
}

Please let me know how I can achieve my filtration logic as well as automatically execute the Select All action once 1 record is filtered, thank you!

Share Improve this question asked Feb 6 at 23:26 Tharidhi PTharidhi P 73 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

The problem is that when Process All runs, it executes the openOrders view delegate multiple times. Since you have only one record, it calls Process All again, which triggers the view delegate, creating a loop. You can use a flag in your graph extension and set it to true the first time after selecting the records.

private bool isInProcessAll = false;

protected virtual IEnumerable openOrders()
{
    ...
   
    if (result.Count == 1)
    {
        try
        {
            isInProcessAll = true;
            Base.Actions["ProcessAll"].Press();
        }
        finally
        {
            isInProcessAll = false;
        }

    }
}
发布评论

评论列表(0)

  1. 暂无评论