Skip to main content
Solved

How to update inventory lookup results grid


Forum|alt.badge.img

Hello!

I’ve made some modifications to the Inventory Lookup smart panel in the Sales Order Screen.

I added a new grid with a Split panel like this:

The left grid shows the available attributes for the selected ItemClassID so that the users can search inventory items by it’s attributes.

The “Search” button on the top of the attributes Grid, goes through the filtered Item list and gets the list of items that matches the user’s attribute selection.

The problem is that I can’t update the right grid with the list of items.

The Callbackcommand in the aspx is the following:

<px:PXDSCallbackCommand Name="AttributeSearch" DependOnGrid="Attributes" Visible="False" />

The button:

<ActionBar>
    <CustomItems>
        <px:PXToolBarButton Text="Search" CommandName="AttributeSearch" DependOnGrid="Attributes" Visible="">
           <AutoCallBack Command="AttributeSearch" Target="ds" />
        </px:PXToolBarButton>
    </CustomItems>
</ActionBar>

In the graph I try to clear the grid cache, loop though the item list and insert the filtered data:

//Getting the list of items
var filteredProducts = ItemResults.Select().RowCast<SOSiteStatusSelected>().ToList();

//Getting the attributes
var AttributesFilter = Attributes.Select().RowCast<USRCBItemSearchAttributes>().ToList();

                if (filteredProducts.Count > 0)
                {
                    // Trying to clear the results grid
                    ItemResults.Cache.Clear();


                    List<string> attVals = new List<string>();
                    foreach (USRCBItemSearchAttributes attOpt in AttributesFilter)
                    {
                        if(attOpt.AttValue != null)
                        {
                            attVals.Add(attOpt.AttValue);
                        }
                    }
                    int attFilterSize = attVals.Count;

                    foreach (SOSiteStatusSelected product in filteredProducts)
                    {
                        SOSiteStatusSelectedExtension selExt = PXCache<SOSiteStatusSelected>.GetExtension<SOSiteStatusSelectedExtension>(product);
                        if (selExt.ItemAttributes != null)
                        {
                            int coincidence = 0;
                            foreach(string vals in attVals)
                            {
                                bool containsVal = selExt.ItemAttributes.Contains(vals);
                                if (containsVal)
                                {
                                    coincidence++;
                                }
                            }
                            if(attFilterSize == coincidence)
                            {
                                ItemResults.Insert(product);
                            }
                        }

                    }
                    ItemResults.View.RequestRefresh();
                }

Hope someone can help me find what’s missing.

Best answer by aaghaei

@albertobello83I gave it another try. My version is 21R2 21.205. Please see the attached clip (change the extension from pdf to mkv) also I made the below changes to your code.

// Replaced your DAC with:
using System;
using PX.Data;
using PX.Data.ReferentialIntegrity.Attributes;
using PX.Objects.CS;
using PX.Objects.IN;

namespace PX.Objects.SO
{
    public class USRCBItemClassEntityType : PX.Data.BQL.BqlString.Constant<USRCBItemClassEntityType>
    {
        public USRCBItemClassEntityType() : base("PX.Objects.IN.InventoryItem") { }
    }

    public class USRCBAttributeCategory : PX.Data.BQL.BqlString.Constant<USRCBAttributeCategory>
    {
        public USRCBAttributeCategory() : base("A") { }
    }


    [Serializable]
    [PXCacheName("Item Search Attributes")]
    [PXProjection(typeof(Select2<CSAttributeGroup,
                            InnerJoin<INItemClass, On<CSAttributeGroup.entityClassID, Equal<INItemClass.itemClassID>>>,
                            Where<CSAttributeGroup.entityType, Equal<USRCBItemClassEntityType>,
                                And<CSAttributeGroup.attributeCategory, Equal<USRCBAttributeCategory>,
                                    And<CSAttributeGroup.isActive, Equal<True>>>>>))]
    public partial class USRCBItemSearchAttributes : PX.Data.IBqlTable
    {
        #region Keys
        public class PK : PrimaryKeyOf<USRCBItemSearchAttributes>.By<attributeID, entityClassID, entityType>
        {
            public static USRCBItemSearchAttributes Find(PXGraph graph, string attributeID, string entityClassID, string entityType) => FindBy(graph, attributeID, entityClassID, entityType);
        }
        #endregion


        #region AttributeID
        public abstract class attributeID : PX.Data.BQL.BqlString.Field<attributeID> { }
        protected string _AttributeID;
        [PXDBString(10, IsKey = true, IsUnicode = true, InputMask = ">aaaaaaaaaa", BqlField = typeof(CSAttributeGroup.attributeID))]
        [PXUIField(DisplayName = "Attribute", Visibility = PXUIVisibility.SelectorVisible)]
        [CSAttributeSelector]
        public virtual string AttributeID
        {
            get { return this._AttributeID; }
            set { this._AttributeID = value; }
        }
        #endregion

        #region EntityClassID
        public abstract class entityClassID : PX.Data.BQL.BqlString.Field<entityClassID> { }
        protected string _EntityClassID;
        [PXDBString(30, IsKey = true, IsUnicode = true, BqlField = typeof(INItemClass.itemClassCD))]
        [PXUIField(DisplayName = "Entity Class", Visibility = PXUIVisibility.SelectorVisible)]
        [PXParent(typeof(Select<SOSiteStatusFilter,
            Where<SOSiteStatusFilter.itemClass, Equal<Current<USRCBItemSearchAttributes.entityClassID>>>>))]
        public virtual string EntityClassID
        {
            get { return this._EntityClassID; }
            set { this._EntityClassID = value; }
        }
        #endregion

        #region EntityType
        public abstract class entityType : PX.Data.BQL.BqlString.Field<entityType> { }
        protected string _EntityType;
        [PXDBString(200, IsKey = true, BqlField = typeof(CSAttributeGroup.entityType))]
        [PXUIField(DisplayName = "Type")]
        public virtual string EntityType
        {
            get { return this._EntityType; }
            set { this._EntityType = value; }
        }
        #endregion

        #region AttValue
        public abstract class attValue : PX.Data.BQL.BqlString.Field<attValue> { }
        protected string _AttValue;
        [PXDBString(255, IsUnicode = true, BqlField = typeof(CSAttributeGroup.defaultValue))]
        [PXUIField(DisplayName = "Value")]
        public virtual string AttValue
        {
            get { return this._AttValue; }
            set { this._AttValue = value; }
        }
        #endregion
    }
}


// Removed the below Event Handler
        protected virtual void _(Events.FieldUpdated<SOSiteStatusFilter, SOSiteStatusFilter.itemClass> e)



// Replaced your Attributes view with

        public PXSelect<USRCBItemSearchAttributes,
            Where<USRCBItemSearchAttributes.entityClassID, Equal<Current<SOSiteStatusFilter.itemClass>>>> Attributes;

 

I am not getting errors now but I guess you will need to look into your search method one more time. I would suggest to re-write the ItemResults view using a view delegate instead of using event handlers. I am not sure but you might know you can generate a value list and use it in the IN operator something like

Object[] values = new String[] { "Att1", "Att2" };
InventoryItem item = PXSelect<InventoryItem,
       Where<InventoryItem.itemStatus,
In<Required<InventoryItem.itemStatus>>>>.Select(Base, values);

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

13 replies

aaghaei
Captain II
Forum|alt.badge.img+9
  • Captain II
  • 1178 replies
  • December 19, 2022

@albertobello83

for all master-detail relationship dataviews this is the instruction should be followed to enable synchronization of child grid to the parent. This can be developed for more than two layers

https://stackoverflow.com/questions/49264233/how-to-create-master-detail-grids-in-acumatica


Forum|alt.badge.img
  • Author
  • Freshman I
  • 11 replies
  • December 20, 2022

Thanks for your answer @aaghaei 

In my case there is no master-detail relation between the two grids. Actually, the left grid works as an additional filter that gets the inventory items by it’s attributes according to what the user puts in the left grid… But I just can’t find the way to show this new results in the right grid.


aaghaei
Captain II
Forum|alt.badge.img+9
  • Captain II
  • 1178 replies
  • December 20, 2022

@albertobello83 Would you like to share the customization package so that I can have a look?


Forum|alt.badge.img
  • Author
  • Freshman I
  • 11 replies
  • December 20, 2022

Yes @aaghaei… Please do take a look

 


aaghaei
Captain II
Forum|alt.badge.img+9
  • Captain II
  • 1178 replies
  • December 20, 2022

@albertobello83 i will have a look tomorrow. Too late tonight here. Meantime others may also get a chance to look into this.


aaghaei
Captain II
Forum|alt.badge.img+9
  • Captain II
  • 1178 replies
  • December 20, 2022

@albertobello83 for clarification, you do not have any ASPX customization other than what you had copied in your post. Is that correct?


Forum|alt.badge.img
  • Author
  • Freshman I
  • 11 replies
  • December 20, 2022

@aaghaei There’s no other aspx customization other than the one in the proyect. Thanks!


aaghaei
Captain II
Forum|alt.badge.img+9
  • Captain II
  • 1178 replies
  • December 21, 2022

@albertobello83 

I got a chance to look into the code you provided but it is missing the ASPX customization. If you would like, please export the customization package from Acumatica Customization Project Editor for this project so that I can review it tomorrow. 


Forum|alt.badge.img
  • Author
  • Freshman I
  • 11 replies
  • December 21, 2022

Thanks @aaghaei 

Here’s the project.

I really appreciate your suggestions


aaghaei
Captain II
Forum|alt.badge.img+9
  • Captain II
  • 1178 replies
  • December 22, 2022

@albertobello83 

I spent quite some time today on this but couldn’t find the root cause. Sorry, but I can not really spend more time on this.

Why don’t you alternatively allow the user to filter on the inventory list as you already have the attributes as part of the items list?


Forum|alt.badge.img
  • Author
  • Freshman I
  • 11 replies
  • December 22, 2022

Thanks for taking the time @aaghaei 

I will try some other options like the one you mentioned.


aaghaei
Captain II
Forum|alt.badge.img+9
  • Captain II
  • 1178 replies
  • Answer
  • December 23, 2022

@albertobello83I gave it another try. My version is 21R2 21.205. Please see the attached clip (change the extension from pdf to mkv) also I made the below changes to your code.

// Replaced your DAC with:
using System;
using PX.Data;
using PX.Data.ReferentialIntegrity.Attributes;
using PX.Objects.CS;
using PX.Objects.IN;

namespace PX.Objects.SO
{
    public class USRCBItemClassEntityType : PX.Data.BQL.BqlString.Constant<USRCBItemClassEntityType>
    {
        public USRCBItemClassEntityType() : base("PX.Objects.IN.InventoryItem") { }
    }

    public class USRCBAttributeCategory : PX.Data.BQL.BqlString.Constant<USRCBAttributeCategory>
    {
        public USRCBAttributeCategory() : base("A") { }
    }


    [Serializable]
    [PXCacheName("Item Search Attributes")]
    [PXProjection(typeof(Select2<CSAttributeGroup,
                            InnerJoin<INItemClass, On<CSAttributeGroup.entityClassID, Equal<INItemClass.itemClassID>>>,
                            Where<CSAttributeGroup.entityType, Equal<USRCBItemClassEntityType>,
                                And<CSAttributeGroup.attributeCategory, Equal<USRCBAttributeCategory>,
                                    And<CSAttributeGroup.isActive, Equal<True>>>>>))]
    public partial class USRCBItemSearchAttributes : PX.Data.IBqlTable
    {
        #region Keys
        public class PK : PrimaryKeyOf<USRCBItemSearchAttributes>.By<attributeID, entityClassID, entityType>
        {
            public static USRCBItemSearchAttributes Find(PXGraph graph, string attributeID, string entityClassID, string entityType) => FindBy(graph, attributeID, entityClassID, entityType);
        }
        #endregion


        #region AttributeID
        public abstract class attributeID : PX.Data.BQL.BqlString.Field<attributeID> { }
        protected string _AttributeID;
        [PXDBString(10, IsKey = true, IsUnicode = true, InputMask = ">aaaaaaaaaa", BqlField = typeof(CSAttributeGroup.attributeID))]
        [PXUIField(DisplayName = "Attribute", Visibility = PXUIVisibility.SelectorVisible)]
        [CSAttributeSelector]
        public virtual string AttributeID
        {
            get { return this._AttributeID; }
            set { this._AttributeID = value; }
        }
        #endregion

        #region EntityClassID
        public abstract class entityClassID : PX.Data.BQL.BqlString.Field<entityClassID> { }
        protected string _EntityClassID;
        [PXDBString(30, IsKey = true, IsUnicode = true, BqlField = typeof(INItemClass.itemClassCD))]
        [PXUIField(DisplayName = "Entity Class", Visibility = PXUIVisibility.SelectorVisible)]
        [PXParent(typeof(Select<SOSiteStatusFilter,
            Where<SOSiteStatusFilter.itemClass, Equal<Current<USRCBItemSearchAttributes.entityClassID>>>>))]
        public virtual string EntityClassID
        {
            get { return this._EntityClassID; }
            set { this._EntityClassID = value; }
        }
        #endregion

        #region EntityType
        public abstract class entityType : PX.Data.BQL.BqlString.Field<entityType> { }
        protected string _EntityType;
        [PXDBString(200, IsKey = true, BqlField = typeof(CSAttributeGroup.entityType))]
        [PXUIField(DisplayName = "Type")]
        public virtual string EntityType
        {
            get { return this._EntityType; }
            set { this._EntityType = value; }
        }
        #endregion

        #region AttValue
        public abstract class attValue : PX.Data.BQL.BqlString.Field<attValue> { }
        protected string _AttValue;
        [PXDBString(255, IsUnicode = true, BqlField = typeof(CSAttributeGroup.defaultValue))]
        [PXUIField(DisplayName = "Value")]
        public virtual string AttValue
        {
            get { return this._AttValue; }
            set { this._AttValue = value; }
        }
        #endregion
    }
}


// Removed the below Event Handler
        protected virtual void _(Events.FieldUpdated<SOSiteStatusFilter, SOSiteStatusFilter.itemClass> e)



// Replaced your Attributes view with

        public PXSelect<USRCBItemSearchAttributes,
            Where<USRCBItemSearchAttributes.entityClassID, Equal<Current<SOSiteStatusFilter.itemClass>>>> Attributes;

 

I am not getting errors now but I guess you will need to look into your search method one more time. I would suggest to re-write the ItemResults view using a view delegate instead of using event handlers. I am not sure but you might know you can generate a value list and use it in the IN operator something like

Object[] values = new String[] { "Att1", "Att2" };
InventoryItem item = PXSelect<InventoryItem,
       Where<InventoryItem.itemStatus,
In<Required<InventoryItem.itemStatus>>>>.Select(Base, values);


Forum|alt.badge.img
  • Author
  • Freshman I
  • 11 replies
  • December 23, 2022

Thank you very much @aaghaei.

I will take out the event handler and replace it with this much functional DAC.

I will also take a look into this delegate method you mentioned.

Thanks a lot!


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