Skip to content

Instantly share code, notes, and snippets.

@tac-ljustiniano
Last active March 20, 2024 20:09
Show Gist options
  • Save tac-ljustiniano/b47e0b708d8bf6378329c9684394b788 to your computer and use it in GitHub Desktop.
Save tac-ljustiniano/b47e0b708d8bf6378329c9684394b788 to your computer and use it in GitHub Desktop.
Removes a Location named "B_INV" from the list of locations based on a selected warehouse (SiteID)
using System;
using PX.Data;
using PX.Data.BQL;
using PX.Objects.IN;
namespace TEST
{
public class LocationExtType
{
public const string B_INV = "B-INV";
public class b_INV : PX.Data.BQL.BqlString.Constant<b_INV>
{
public b_INV() : base(B_INV) { }
}
}
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;
}
}
public class InventorySummaryEnq_Extension : PXGraphExtension<PX.Objects.IN.InventorySummaryEnq>
{
public static bool IsActive() => true; // Check for Feature
[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) { }
}
}
using System;
using PX.Data;
using PX.Data.BQL;
using PX.Objects.IN;
namespace TEST
{
public class LocationExtType
{
public const string B_INV = "B-INV";
public class b_INV : PX.Data.BQL.BqlString.Constant<b_INV>
{
public b_INV() : base(B_INV) { }
}
}
public class InventorySummaryEnq_Extension : PXGraphExtension<PX.Objects.IN.InventorySummaryEnq>
{
public static bool IsActive() => true; // Check for Feature
[PXMergeAttributes(Method = MergeMethod.Append)]
[PXRestrictor(typeof(Where<INLocation.locationCD, NotEqual<LocationExtType.b_INV>>),"")]
protected void _(Events.CacheAttached<InventorySummaryEnqFilter.locationID> e) { }
}
}
@tac-ljustiniano
Copy link
Author

Simple version added after good note by Daryl Bowman

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment