Solved

SO Line Inventory ID Cache Attached Issue

  • 6 September 2022
  • 6 replies
  • 173 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;
}
}
}
}

 

icon

Best answer by Dioris Aguilar 7 September 2022, 18:13

View original

6 replies

Userlevel 5
Badge +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.

@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.

Userlevel 3
Badge

@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

@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

Userlevel 5
Badge +2

@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 

@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


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved