June B
June B

Reputation: 142

Custom field with InventoryAttribute and PXRestrictor based on ItemClass no longer working in 2018R1

We have a custom field with a lookup/selector for Inventory Item that I had restricted to only a certain item class. With 2018R1, the ItemClassID field is now an int and I need to compare to the ItemClassCD field.

My PXRestrictor can only access fields from the original DAC. How best should I rewrite this to accommodate the change to the item class?

        #region ParentInventoryID
    [Inventory( IsKey = true, Visibility = PXUIVisibility.SelectorVisible, DisplayName = "Parent Inventory ID")]
    [PXRestrictor(typeof(Where<InventoryItem.itemClassID, Equal<ItemClass.cabledTransceiverFinishedProduct>>), "Parent is not a cabled transceiver finished product.")]
    [PXDefault()]
    [PX.Data.EP.PXFieldDescription] 
    [PXParent(typeof(Select<InventoryItem, Where<InventoryItem.inventoryID, Equal<Current<parentInventoryID>>>>))]
    public Int32? ParentInventoryID { get; set; }
    public abstract class parentInventoryID : IBqlField { }
    #endregion

Upvotes: 0

Views: 324

Answers (1)

Hugues Beaus&#233;jour
Hugues Beaus&#233;jour

Reputation: 8278

A new table INItemClass has been created to store the Inventory Item Class. InventoryItem.INItemClassID key field points to a INItemClass record.

I think that the Inventory attribute doesn't join the INItemClass by default so you would have to add that join in the attribute type parameter.

With the INItemClass join you can restrict on the text field INItemClass.itemClassCD:

[Inventory(typeof(Search2<InventoryItem.inventoryID, 
                  InnerJoin<INItemClass, On<INItemClass.itemClassID, Equal<InventoryItem.itemClassID>>>>),
           typeof(InventoryItem.inventoryCD), 
           typeof(InventoryItem.descr), 
           DisplayName = "Parent Inventory ID")]
[PXRestrictor(typeof(Where<INItemClass.itemClassCD, Equal<ItemClass.cabledTransceiverFinishedProduct>>), "Parent is not a cabled transceiver finished product.")]

Upvotes: 1

Related Questions