how can i customize the inventory id selector?

PXRestrictor is used with a where clause to specify how to restrict.

[PXRestrictor(typeof(
    Where<Current<InventoryItem.itemClassID>, Equal<itemClassValue>>
    ), "Custom Items")]

In the example above, itemClassValue must be a type of the classID.

You can Merge with current attributes on the field where the selector is defined as a DAC extension if it needs to exist everywhere or with CacheAttached if only within a specific graph.

Update

As you indicated that you need to allow an entire tree of item classes in the comments, you might try this approach which worked for me in a case where I needed to only allow certain values on a condition.

Add a PXInt field onto SOLine for your BASE item class. Use the RowSelecting event to set it, and then use it in your restrictor.

Sample Base Item Class ID field:

#region BaseItemClassID
[PXInt]
public virtual int? BaseItemClassID { get; set; }
public abstract class baseItemClassID : PX.Data.BQL.BqlInt.Field<baseItemClassID> { }
#endregion

Restrictor to use in CacheAttached to limit to only items of your base item class:

[PXRestrictor(typeof(Where<InventoryItem.baseItemClassID, Equal<myBaseItemClassType>>), "")]

If this is applied to all SOLine records, you will need to add your “when to allow only my specific item class tree” to the restrictor. Remember that the restrictor must return True to give results, so it might need to be “Where NOT my condition OR BaseItemClassID == myBaseItemClassID”.

In my case, I needed a simple condition to allow using standard locations where I have some locations configured as special use for segregating certain inventory. I just set a PXBool field to true when I want to allow use of standard locations, and the restrictor flips the allowed selection. I think this concept might work in your case as well as outlined above.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top