Why not simply use [CrossItem] ? The POReceiptLineInventory attribute simply inherits from CrossItem and adds a filter to prevent you from selecting items that have status set to No Purchases. CrossItemAttribute itself inherits from the same base class as StockItemsAttribute - you don’t need to use StockItem as well.
>PXDBInt()]
rPXUIField(DisplayName = "Inventory ID", Visibility = PXUIVisibility.Visible)]
public class POReceiptLineInventoryAttribute : CrossItemAttribute
{
public POReceiptLineInventoryAttribute(Type receiptType)
: base(typeof(Search<InventoryItem.inventoryID, Where<Match<Current<AccessInfo.userName>>>>), typeof(InventoryItem.inventoryCD), typeof(InventoryItem.descr), INPrimaryAlternateType.VPN)
{
var condition = BqlTemplate.OfCondition<
Where<Current2<BqlPlaceholder.A>, Equal<POReceiptType.transferreceipt>,
Or<InventoryItem.itemStatus, NotEqual<InventoryItemStatus.noPurchases>>>>
.Replace<BqlPlaceholder.A>(receiptType)
.ToType();
_Attributes.Add(new PXRestrictorAttribute(condition, IN.Messages.ItemCannotPurchase));
}
}
Thank you for your reply - I appreciate you digging into that.
I had tried adjusting the attributes via a Graph Extension but entering the barcode or global cross-reference returned an error.
public class INTransferEntry_Extension : PXGraphExtension<INTransferEntry>
{
#region Event Handlers
//>PXDefault()]
// StockItem(DisplayName="Inventory ID")]
//
bCrossItem]
protected virtual void INTran_InventoryID_CacheAttached(PXCache cache)
{
}
#endregion
}
So maybe there’s something else going on within the Transfer logic that I need to dig through more because I get an on-screen error:
“Error: An error occurred during processing of the field InventoryID: Value cannot be null. Parameter name: key.”
The error trace starts with:
”The item InventoryID is not found (restricted:False,external:True,value:THATLEGOPT)“
Then:
“Value cannot be null.
Parameter name: key
at PX.Data.PXCache`1.FillWithValues(TNode item, TNode copy, IDictionary values, PXCacheOperation operation, Boolean externalCall)“
And finally, the error that is shown on the screen (listed above).
I did some troubleshooting and found the issue -- the CrossItem attribute doesn’t work with the default constructor; I think this is simply because there are no places in Acumatica where it is used this way.
Even though you don’t have a customer or vendor field in Inventory Tranfers, I managed to get it to work this way:
"CrossItem(INPrimaryAlternateType.CPN, Filterable = true, BqlField = typeof(INTran.inventoryID))]
protected virtual void INTran_InventoryID_CacheAttached(PXCache cache)
{
}
Right on! Thanks for digging into that!