Как я могу изменить селектор местоположения для экрана заказов на продажу - PullRequest
0 голосов
/ 24 января 2020

У меня есть запрос на добавление полей в селектор для местоположения на экране «Заказ на продажу». В стандартном стиле 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. Как бы я добавил эти поля в этот crypti c селектор под названием 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) { }

1 Ответ

0 голосов
/ 24 января 2020

Это немного сложно, потому что возможность изменять список столбцов защищена. Мы можем изменить столбцы, создав собственный атрибут идентификатора местоположения, который наследует тот, который нам нужно изменить, и затем заменить селектор Dimension, который в то время может добавить столбцы для отображения. Нам также нужно присоединиться к таблице адресов, чтобы отобразить поля, которые вы хотите добавить, поскольку их нет в Location DA C.

. Вот рабочие примеры:

Новый атрибут который мы будем использовать для замены текущего атрибута в 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)]

И мы получим следующее:

enter image description here

...