可以更改客户ID的查询

时间:2018-11-28 17:36:32

标签: acumatica

在销售订单屏幕中,是否可以更改销售订单屏幕中可用的客户选择?就我而言,只有某些客户可用于特定的分支机构和特定的订单类型。换句话说,根据分支和订单类型提供客户列表。我知道我们可以通过使用自定义PXSelectorAttribute重新定义查找控件。但是,对于客户ID查找,我还是很犹豫。具体来说,我想知道这是一个不好的方法。

我使用的版本是2017 R2。

1 个答案:

答案 0 :(得分:0)

作为示例,我们将“客户”限制为已登录的SalesPerson。 SalesPerson限于FieldTicket(FT)自定义OrderType。该方法对我们来说效果很好。详细信息:

自定义属性:

[PXDBInt()]
[PXUIField(DisplayName = "Customer", Visibility = PXUIVisibility.Visible)]
[PXRestrictor(typeof(Where<Customer.status, IsNull,
                    Or<Customer.status, Equal<BAccount.status.active>,
                    Or<Customer.status, Equal<BAccount.status.oneTime>>>>),
                            PX.Objects.AR.Messages.CustomerIsInStatus, typeof(Customer.status))]
public sealed class CustomerRepAttribute : AcctSubAttribute
{
    public const string DimensionName = "CUSTOMER";

    public CustomerRepAttribute(Type WhereType)
    {
        Type cmd = BqlCommand.Compose(
                        typeof(Search5<,,,,>),
                        typeof(BAccountR.bAccountID),
                        typeof(LeftJoin<,,>),
                        typeof(Customer),
                        typeof(On<Customer.bAccountID, Equal<BAccountR.bAccountID>, And<Match<Customer, Current<AccessInfo.userName>>>>),

                        typeof(LeftJoin<,,>),
                        typeof(CustSalesPeople),
                        typeof(On<Customer.bAccountID, Equal<CustSalesPeople.bAccountID>>),

                        typeof(LeftJoin<,,>),
                        typeof(SalesPerson),
                        typeof(On<CustSalesPeople.salesPersonID, Equal<SalesPerson.salesPersonID>>),

                        typeof(LeftJoin<,,>),
                        typeof(EPEmployee),
                        typeof(On<Optional<AccessInfo.userID>, Equal<EPEmployee.userID>>),

                        typeof(LeftJoin<,,>),
                        typeof(Contact),
                        typeof(On<Contact.bAccountID, Equal<BAccountR.bAccountID>, And<Contact.contactID, Equal<BAccountR.defContactID>>>),
                        typeof(LeftJoin<,,>),
                        typeof(Address),
                        typeof(On<Address.bAccountID, Equal<BAccountR.bAccountID>, And<Address.addressID, Equal<BAccountR.defAddressID>>>),
                        typeof(LeftJoin<,>),
                        typeof(Location),
                        typeof(On<Location.bAccountID, Equal<BAccountR.bAccountID>, And<Location.locationID, Equal<BAccountR.defLocationID>>>),

                        WhereType,
                        typeof(Aggregate<GroupBy<BAccountR.bAccountID, GroupBy<BAccountR.acctCD, GroupBy<Customer.acctName>>>>),
                        typeof(OrderBy<Asc<BAccountR.acctCD>>)

                        );

        PXDimensionSelectorAttribute attr;
        _Attributes.Add(attr = new PXDimensionSelectorAttribute(DimensionName, cmd, typeof(BAccountR.acctCD),
            typeof(BAccountR.acctCD), typeof(Customer.acctName), typeof(Customer.customerClassID),
            typeof(Customer.status), typeof(Contact.phone1), typeof(Address.city), typeof(Address.countryID)
        ));
        attr.DescriptionField = typeof(Customer.acctName);
        attr.CacheGlobal = true;
        attr.FilterEntity = typeof(Customer);
        _SelAttrIndex = _Attributes.Count - 1;
        this.Filterable = true;

    }
}

它用作DAC替代:

    [PXDefault]
    [CustomerRep(typeof(Where2<Where2<Where<Customer.type, IsNotNull,
                                       And<Current<SOOrder.orderType>, NotEqual<string_FT>,
                                            Or<Where<Current<SOOrder.orderType>, Equal<string_FT>,
                                                And<Current<Users.pKID>, IsNull>>>>>,
                                    Or<Where<Current<SOOrder.aRDocType>, Equal<ARDocType.noUpdate>,
                                        Or<Customer.type, Equal<BAccountType.companyType>>>>>,
                            Or<Where<Current<SOOrder.orderType>, Equal<string_FT>,
                                        And<SalesPerson.salesPersonID, Equal<EPEmployee.salesPersonID>,
                                        And<Current<Users.pKID>, IsNotNull>>>>>),

        Visibility = PXUIVisibility.SelectorVisible, DescriptionField = typeof(Customer.acctName), Filterable = true)]
    [PXUIField(DisplayName = "Customer", Visibility = PXUIVisibility.SelectorVisible)]
    protected virtual void SOOrder_CustomerID_CacheAttached(PXCache sender) { }