I am trying to filter out/hide a location id in the selector for the Inventory Summary screen.

Any ideas on this would be appreciated. Thanks in advance!
I am trying to filter out/hide a location id in the selector for the Inventory Summary screen.
Any ideas on this would be appreciated. Thanks in advance!
Best answer by Leonardo Justiniano
Hi
You have to override the attribute Location and modify the internal selector to accommodate your new filtering criteria. In the following example I am adding value “ExcuideLoc” which will be used to exclude a specific location:
public class LocationExtAttribute : LocationAttribute
{
public LocationExtAttribute(Type SiteIDType, Type ExcludeLoc) : base(SiteIDType)
{
_SiteIDType = SiteIDType ?? throw new PXArgumentException(nameof(SiteIDType), ErrorMessages.ArgumentNullException);
Type search = BqlTemplate.OfCommand<
Search<INLocation.locationID,
Where<INLocation.siteID, Equal<Optional<BqlPlaceholder.A>>,
And<INLocation.locationCD, NotEqual<BqlPlaceholder.B>>>>>
.Replace<BqlPlaceholder.A>(_SiteIDType)
.Replace<BqlPlaceholder.B>(ExcludeLoc)
.ToType();
var attr = new LocationDimensionSelectorAttribute(search, GetSiteIDKeyRelation(SiteIDType));
_Attributes.Add(attr);
_SelAttrIndex = _Attributes.Count - 1;
}
}
Once that is implemented you need to replace the current attribute on the field LocationID with the new attribute:
[PXMergeAttributes(Method = MergeMethod.Replace)]
[LocationExt(typeof(InventorySummaryEnqFilter.siteID), typeof(LocationExtType.b_INV), Visibility = PXUIVisibility.Visible, KeepEntry = false, DescriptionField = typeof(INLocation.descr), DisplayName = "Location")]
protected void _(Events.CacheAttached<InventorySummaryEnqFilter.locationID> e) { }
Note that I am passing typeof(LoccationExtType.b_INV) which is a standard constant I defined.
You can find the full example here:
Inventory Summary Screen
Before
After
Other options
You can write directly the query using PXDimensionSelector attribute, but will change the original idea of having all encapsulated within the Location attribute implementation.
Hope this approach helps.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.