Skip to main content
Solved

SO Line Inventory ID Cache Attached Issue

  • September 6, 2022
  • 6 replies
  • 239 views

Hi, 

I am trying to customize or filter the Inventory ID Lookup on the Sales Order Screen (SO30100) by using SOLine_InventoryID_CacheAttached. Whenever I select the item, the grid line is filled up with the internal inventory ID value instead of the inventory CD.

After selecting the item

 Here is my code

 

public class SOOrderEntry_Extension : PXGraphExtension<PX.Objects.SO.SOOrderEntry>
    {


        [PXMergeAttributes(Method = MergeMethod.Append)]
        [InventorySelectorCustom(typeof(InventoryItem.inventoryCD))]
        protected virtual void SOLine_InventoryID_CacheAttached(PXCache cache)
        {
        }


        [Serializable]
        public class InventorySelectorCustom : PXCustomSelectorAttribute
        {
            public InventorySelectorCustom(Type type)
                : base(type,   typeof(InventoryItem.inventoryCD),typeof(InventoryItem.descr)
                      , typeof(InventoryItem.itemClassID), typeof(InventoryItem.itemStatus), typeof(InventoryItem.itemType)
                      , typeof(InventoryItem.baseUnit), typeof(InventoryItem.salesUnit), typeof(InventoryItem.purchaseUnit)
                      , typeof(InventoryItem.basePrice), typeof(InventoryItem.exportToExternal))
            {
            }
            public virtual IEnumerable GetRecords()
            {
                SOLine currentItem = (SOLine)this._Graph.Views["Transactions"].Cache.Current;
                if (currentItem == null)
                {
                    return null;
                }
                else
                {

                    SOOrder currentOrder = (SOOrder)this._Graph.Views["Document"].Cache.Current;

                    List<InventoryItem> items = new List<InventoryItem>();
                    var allitems = PXSelect<InventoryItem>.Select(this._Graph);
                    foreach (var it in allitems)
                    {
                        InventoryItem rec = (InventoryItem)it[0];
                        items.Add(rec);
                    }
                    return items;
                }
            }
        }
    }

 

Best answer by Dioris Aguilar

@bryanvelez81 Had some time to review it and this what needs to be done to make your code work:
 

[PXMergeAttributes(Method = MergeMethod.Append)]
        [InventorySelectorCustom(typeof(InventoryItem.inventoryID), SubstituteKey = typeof(InventoryItem.inventoryCD))]
        protected virtual void SOLine_InventoryID_CacheAttached(PXCache cache)
        {
        }

Try using the PXSelector + PXRestrictor instead as mentioned by @gprice27 

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

6 replies

Dioris Aguilar
Jr Varsity I
Forum|alt.badge.img+2

@bryanvelez81 Try adding this to the cacheAttached to prevent having two selector attributes on the same field:

[PXRemoveBaseAttribute(typeof(SOLineInventoryItemAttribute))]

According to the code provided, your custom selector lists all inventory item records if the current is not null showing some specific columns. Maybe you can use PXSelector<InventoryItem> and define the columns you want.

Remember also you can use this PXCustomizeSelectorColumns attribute to customize the columns you would like to show using the selector attribute already existing in the field.


  • Author
  • Freshman I
  • 3 replies
  • September 7, 2022

@Dioris Aguilar tried adding the PXRemoveBaseAttribute and the PXCustomizeSelectorColumns but I am having the same issue. For a moment the Inventory CD shows up but then it gets changed to the internal Inventory ID integer.


gprice27
Jr Varsity I
Forum|alt.badge.img
  • Jr Varsity I
  • 25 replies
  • September 7, 2022

@bryanvelez81

It is not clear what you are trying to accomplish with your custom selector - are you wishing to add columns to the selector grid - or are you trying to filter what is showing up in the selector grid?

I agree with @Dioris Aguilar about removing the base Selector Attribute first - HOWEVER - there may be other Graph extensions in play which are also modifying the selector - so you might be better to keep the existing selector and use a PXRestrictor to filter what is showing in the grid?

example https://asiablog.acumatica.com/2016/08/using-of-pxrestrictorattribute.html

The other alternative is to just use a simple PXSelector attribute with the BQL you need defined in the parameters (example in above link)

cheers


  • Author
  • Freshman I
  • 3 replies
  • September 7, 2022

@gprice27 I am trying to filter what is showing up in the selector grid. In the example code I am just getting all items but I have to filter the selector grid based on a value of an extension DAC field in the customer table and on ARSalesPrice tables. The DAC extension field basically will indicate if the filter should happen or not. I will try with the PXRestrictor


Dioris Aguilar
Jr Varsity I
Forum|alt.badge.img+2
  • Jr Varsity I
  • 91 replies
  • Answer
  • September 7, 2022

@bryanvelez81 Had some time to review it and this what needs to be done to make your code work:
 

[PXMergeAttributes(Method = MergeMethod.Append)]
        [InventorySelectorCustom(typeof(InventoryItem.inventoryID), SubstituteKey = typeof(InventoryItem.inventoryCD))]
        protected virtual void SOLine_InventoryID_CacheAttached(PXCache cache)
        {
        }

Try using the PXSelector + PXRestrictor instead as mentioned by @gprice27 


  • Author
  • Freshman I
  • 3 replies
  • September 7, 2022

@Dioris Aguilar  adding the substitute key worked. Thanks! Seems that by customizing the selector , the default substitute key was  changed to the InventoryID field.


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