首页 > 解决方案 > Acumatica 中动态变化的仓库选择器

问题描述

我想在以下屏幕上动态更改 Acumatica 中的仓库选择器结果:

,由公司(选定公司下的所有仓库)或分公司。我添加到库存首选项屏幕的自定义字段将满足该条件。

我得出的结论是必须使用自定义选择器属性,但我不确定如何实现这一点。

任何指导和帮助将不胜感激。

请参阅我的自定义 DAC 字段的附加代码和销售订单图的代码:

数模转换器

public class INSetupExt : PXCacheExtension<PX.Objects.IN.INSetup>
    {
        #region UsrAllowBlockin
        [PXDBBool]
        [PXDefault(false)]
        [PXUIField(DisplayName="Block Normal Journal Posting by Creator")]

        public virtual bool? UsrAllowBlockin { get; set; }
        public abstract class usrAllowBlockin : PX.Data.BQL.BqlBool.Field<usrAllowBlockin> { }
        #endregion

        #region UsrByCompany
        [PXDBBool]
        [PXDefault(true)]
        [PXUIField(DisplayName="By Company")]
        [PXUIEnabled(typeof(Where<usrAllowBlockin, NotEqual<False>>))]
        [PXUIVisible(typeof(Where<usrAllowBlockin, NotEqual<False>>))]

        public virtual bool? UsrByCompany { get; set; }
        public abstract class usrByCompany : PX.Data.BQL.BqlBool.Field<usrByCompany> { }
        #endregion

        #region UsrByBranch
        [PXDBBool]
        [PXDefault(false)]
        [PXUIField(DisplayName="By Branch")]
        [PXUIEnabled(typeof(Where<usrAllowBlockin, NotEqual<False>>))]
        [PXUIVisible(typeof(Where<usrAllowBlockin, NotEqual<False>>))]

        public virtual bool? UsrByBranch { get; set; }
        public abstract class usrByBranch : PX.Data.BQL.BqlBool.Field<usrByBranch> { }
        #endregion
    }

图形

protected void SOLine_BranchID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated InvokeBaseHandler)
        {
            if (InvokeBaseHandler != null)
                InvokeBaseHandler(cache, e);
            var row = (SOLine)e.Row;

            INSetupExt extINSetup = Base.insetup.SelectSingle().GetExtension<INSetupExt>();


            if (row != null)
            {
                //retrieve current branch
                int? currentSelectedBranch = Base.Document.Current?.BranchID;
                int currentSelectedCompany = PX.Data.Update.PXInstanceHelper.CurrentCompany;

                //See what condition is selected 
                //If filter by branch is selected, based on the branch selected in the financial tab,
                //allow selection of all warehouses linked the transaction branch only
                //Else if filter by company is selected,
                //allow selection of all warehouses linked to the company or branches within the company associated with the document branch.

                if (extINSetup.UsrAllowBlockin == true && extINSetup.UsrByBranch == true)
                {

                }
                else if (extINSetup.UsrAllowBlockin == true && extINSetup.UsrByCompany == true)
                {

                }
            }
        }

标签: c#acumatica

解决方案


我将在 soLine 上添加一个自定义未绑定字段(作为 int?usrSiteEntityID),该字段由您的字段更新设置(确保默认设置),然后按如下方式覆盖 SiteID 选择器(这是一个非常粗略的示例):

搜索 INSite.siteId,其中 INSite.branch 等于 usrSiteEntityID 或 INSite.company 等于 usrSiteEntityID

然后你可以用一个简单的选择器来做


推荐阅读