【问题标题】:How can I modify the Location selector for Sales Orders screen如何修改销售订单屏幕的位置选择器
【发布时间】:2020-01-24 14:31:10
【问题描述】:

我有一个在销售订单屏幕上向位置选择器添加字段的请求。在标准 Acumatica 风格中,这不是典型的选择器,而是我以前从未见过的:

[LocationID(typeof(Where<Location.bAccountID, Equal<Current<SOOrder.customerID>>,
                   And<Location.isActive, Equal<True>,
                   And<MatchWithBranch<Location.cBranchID>>>>)
            ,DescriptionField = typeof(Location.descr)
            ,Visibility = PXUIVisibility.SelectorVisible)]

我需要添加的字段是 Address1、Address2、City、State、Zip。我如何将这些字段添加到这个名为“LocationID”的神秘选择器中?

这个我试过了,还是不行:

    [PXRemoveBaseAttribute(typeof(LocationIDAttribute))]
    [PXMergeAttributes(Method = MergeMethod.Append)]
    [PXSelector(typeof(Search2<Location.locationID, 
                               InnerJoin<Address, 
                                   On<Location.defAddressID, Equal<Address.addressID>>>,
                       Where<Location.bAccountID, Equal<Current<SOOrder.customerID>>,
                       And<Location.isActive, Equal<True>,
                       And<MatchWithBranch<Location.cBranchID>>>>>)
                ,typeof(Location.locationCD)
                ,typeof(Address.addressLine1)
                ,typeof(Address.addressLine2)
                ,typeof(Address.city)
                ,typeof(Address.state)
                ,typeof(Address.postalCode)
                ,SubstituteKey = typeof(Location.locationCD)
                ,DescriptionField = typeof(Location.descr))]
    protected virtual void SOOrder_CustomerLocationID_CacheAttached(PXCache sender) { }

【问题讨论】:

    标签: acumatica


    【解决方案1】:

    这个有点棘手,因为更改列列表的能力受到保护。我们可以通过创建我们自己的位置 ID 属性来更改列,该属性继承我们需要更改的属性,然后替换维度选择器,那时我们可以添加要显示的列。我们还需要加入地址表以显示您要添加的字段,因为它们不在 Location DAC 中。

    以下是工作示例:

    我们将使用一个新属性来替换 SOOrder CustomerLocaitonID 上的当前属性

    public class LocationIDExtensionAttribute : LocationIDAttribute
    {
        public LocationIDExtensionAttribute(params Type[] fieldList)
            : this(typeof(Where<boolTrue, Equal<boolTrue>>), fieldList)
        {
        }
    
        public LocationIDExtensionAttribute(Type WhereType, params Type[] fieldList)
            : base(WhereType)
        {
            AddColumns(WhereType, fieldList);
        }
    
        public LocationIDExtensionAttribute(Type WhereType, Type JoinType, params Type[] fieldList)
            : base(WhereType, JoinType)
        {
            AddColumns(WhereType, JoinType, fieldList);
        }
    
        protected void AddColumns(Type WhereType, params Type[] fieldList)
        {
            var dimensionSelector = _Attributes[_SelAttrIndex];
            if (dimensionSelector == null)
            {
                return;
            }
    
            _Attributes[_SelAttrIndex] = (PXEventSubscriberAttribute)new PXDimensionSelectorAttribute("LOCATION", BqlCommand.Compose(typeof(Search<,>), typeof(Location.locationID), WhereType), typeof(Location.locationCD), fieldList);
        }
    
        protected void AddColumns(Type WhereType, Type JoinType, System.Type[] fieldList)
        {
            var dimensionSelector = _Attributes[_SelAttrIndex];
            if (dimensionSelector == null)
            {
                return;
            }
    
            _Attributes[_SelAttrIndex] = (PXEventSubscriberAttribute)new PXDimensionSelectorAttribute("LOCATION", BqlCommand.Compose(typeof(Search2<,,>), typeof(Location.locationID), JoinType, WhereType), typeof(Location.locationCD), fieldList);
        }
    }
    

    然后我们会像这样使用这个属性:

    [LocationIDExtension(typeof(Where<Location.bAccountID, Equal<Current<SOOrder.customerID>>,
            And<Location.isActive, Equal<True>,
                And<MatchWithBranch<Location.cBranchID>>>>),
        typeof(LeftJoin<Address, On<Location.defAddressID, Equal<Address.addressID>>>), 
        typeof(Location.locationCD),
        typeof(Location.descr), 
        typeof(Address.addressLine1), 
        typeof(Address.addressLine2), 
        typeof(Address.city),
        typeof(Address.state), 
        typeof(Address.postalCode), 
        DescriptionField = typeof(Location.descr),
        Visibility = PXUIVisibility.SelectorVisible)]
    

    我们最终得到了这个:

    【讨论】:

    • 这真是太棒了——完美地工作!非常感谢,布伦丹。 ;D
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-09-13
    • 2021-06-08
    • 1970-01-01
    • 2023-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多