Acumatica分行和分行账户扩展更新公司所有分行扩展记录

Acumatica分行和分行账户扩展更新公司所有分行扩展记录,acumatica,Acumatica,我正在尝试将默认分支位置字段添加到分支。此字段允许用户选择一个分支位置作为默认位置,并在将来的多个自定义中使用此默认位置。我的问题是,当我填充新的扩展字段时,该值会保存在所有分支记录上,而不是保存在选定的分支上 我扩展了分支DAC,因为它是存储数据的地方: //Branch Extension [PXTable(typeof(Branch.branchID), IsOptional = false)] public class BranchExtension : PXCacheExtension

我正在尝试将默认分支位置字段添加到分支。此字段允许用户选择一个分支位置作为默认位置,并在将来的多个自定义中使用此默认位置。我的问题是,当我填充新的扩展字段时,该值会保存在所有分支记录上,而不是保存在选定的分支上

我扩展了分支DAC,因为它是存储数据的地方:

//Branch Extension
[PXTable(typeof(Branch.branchID), IsOptional = false)]
public class BranchExtension : PXCacheExtension<Branch>
{
    #region DefaultBranchLocation
    public abstract class defaultBranchLocation : IBqlField { }
    [PXDBInt()]
    [PXUIField(DisplayName = "Default Branch Location")]
    [PXSelector(typeof(FSBranchLocation.branchLocationID),
        DescriptionField = typeof(FSBranchLocation.descr),
        SubstituteKey = typeof(FSBranchLocation.branchLocationCD))]
    public virtual int? DefaultBranchLocation { get; set; }
    #endregion
}
请注意,它不会对关键字段进行过滤

我以前从未遇到过扩展表的问题,所以我不确定我做错了什么。我的猜测是,它与投影的扩展有关,但我在扩展中的字段声明与在投影上声明的字段没有什么不同,这些字段正确保存


非常感谢您的帮助。先谢谢你

实际上,您的问题与您自定义投影的尾部有关。 我建议考虑将数据存储在BACK扩展中。然后,如果需要,您可以使用PXDBSCALARTIBUTE将字段从BAccount映射到分支扩展。 如果您强烈需要避免subselect或有其他要求,您可以执行以下操作:将BranchID字段添加到分支扩展并手动处理此字段

请参见下面的两个示例

public class BranchMaintExt : PXGraphExtension<BranchMaint>
{
    protected void BranchBAccount_BranchID_CommandPreparing(PXCache sender, PXCommandPreparingEventArgs e)
    {
        if ((e.Operation & PXDBOperation.Command) != PXDBOperation.Select && e.Table != typeof(BranchExtension))
        {
            e.Cancel = true;
        }
        else if ((e.Operation & PXDBOperation.Command) == PXDBOperation.Update && e.Value == null && e.Row != null)
        {
            decimal? ident = PXDatabase.SelectIdentity<PX.Objects.GL.Branch>(typeof(PX.Objects.GL.Branch.branchID).Name);
            if (ident != null && ident.Value > 0)
            {
                sender.SetValue<BranchBAccountExtension.branchID>(e.Row, Convert.ToInt32(ident));
                e.Value = ident;
            }
        }
    }

    protected void BranchBAccount_BAccountID_CommandPreparing(PXCache sender, PXCommandPreparingEventArgs e)
    {
        if (((e.Operation & PXDBOperation.Command) == PXDBOperation.Update)
            && sender.GetValue<BranchBAccountExtension.branchID>(e.Row) == null && e.Row != null)
        {
            decimal? ident = PXDatabase.SelectIdentity<PX.Objects.GL.Branch>(typeof(PX.Objects.GL.Branch.branchID).Name);
            if (ident != null && ident.Value > 0)
            {
                sender.SetValue<BranchBAccountExtension.branchID>(e.Row, Convert.ToInt32(ident));
            }
        }
    }
}

[PXTable(typeof(Branch.branchID), IsOptional = false)]
public class BranchExtension : PXCacheExtension<Branch>
{
    #region DefaultBranchLocation
    public abstract class defaultBranchLocation : IBqlField { }
    [PXDBInt()]
    [PXUIField(DisplayName = "Default Branch Location")]
    public virtual int? DefaultBranchLocation { get; set; }
    #endregion

    #region BAccountDefaultBranchLocation
    public abstract class bAccountDefaultBranchLocation : IBqlField { }
    [PXDBScalar(typeof(Search<BAccountExtension.bAccountDefaultBranchLocation, Where<BAccount.bAccountID, Equal<Branch.bAccountID>>>))]
    [PXInt()]
    [PXUIField(DisplayName = "Default Branch Location")]
    public virtual int? BAccountDefaultBranchLocation { get; set; }
    #endregion
}

[PXTable(typeof(BAccount.bAccountID), IsOptional = false)]
public class BAccountExtension : PXCacheExtension<BAccount>
{
    #region BAccountDefaultBranchLocation
    public abstract class bAccountDefaultBranchLocation : IBqlField { }

    [PXDBInt()]
    [PXUIField(DisplayName = "Default Branch Location")]
    public virtual int? BAccountDefaultBranchLocation { get; set; }
    #endregion
}

public class BranchBAccountExtension : PXCacheExtension<BranchMaint.BranchBAccount>
{
    #region BranchID
    public abstract class branchID : PX.Data.IBqlField
    {
    }
    [PXDBInt(BqlField = typeof(PX.Objects.GL.Branch.branchID))]
    [PXUIField(DisplayName = "Branch ID", Visibility = PXUIVisibility.Invisible)]
    public virtual int? BranchID { get; set; }

    #endregion

    #region DefaultBranchLocation
    public abstract class defaultBranchLocation : IBqlField { }
    [PXDBInt(BqlField = typeof(BranchExtension.defaultBranchLocation))]
    [PXUIField(DisplayName = "Default Branch Location")]
    public virtual int? DefaultBranchLocation { get; set; }
    #endregion

    #region BAccountDefaultBranchLocation
    public abstract class bAccountDefaultBranchLocation : IBqlField { }

    [PXDBInt]
    [PXUIField(DisplayName = "Default Branch Location")]
    public virtual int? BAccountDefaultBranchLocation { get; set; }
    #endregion
}

谢谢你的建议。我终于回到了这项任务,并利用你的建议,使它能够工作。具体来说,将新的扩展表/字段从Branch更改为BAccount基本上就是全部。我的投影扩展也被更新为BAccountExtension,而不是BranchExtension。我希望我知道为什么扩展分支会引起问题,但我很高兴我能够通过一个相对较小的更改来解决这个问题。
//BranchBAccount Projection Extension
public class BranchBAccountExtension : PXCacheExtension<BranchMaint.BranchBAccount>
{
    #region DefaultBranchLocation
    public abstract class defaultBranchLocation : IBqlField { }
    [PXDBInt(BqlField = typeof(BranchExtension.defaultBranchLocation))]
    [PXUIField(DisplayName = "Default Branch Location")]
    [PXSelector(typeof(
        Search2<FSBranchLocation.branchLocationID,
            InnerJoin<Branch, On<Branch.branchID, Equal<FSBranchLocation.branchID>>>,
            Where<Branch.branchCD, Equal<Current<BranchMaint.BranchBAccount.branchBranchCD>>>>),
        DescriptionField = typeof(FSBranchLocation.descr),
        SubstituteKey = typeof(FSBranchLocation.branchLocationCD))]
    public virtual int? DefaultBranchLocation { get; set; }
    #endregion
}
...
<px:PXLayoutRule runat="server" StartGroup="True" GroupCaption="Misc Settings (Shared)" ></px:PXLayoutRule>
<px:PXSelector runat="server" ID="edDefaultBranchLocation" DataField="DefaultBranchLocation" CommitChanges="True" AutoRefresh="True" />
<px:PXFormView ID="CommonSettings" runat="server" DataMember="commonsetup" DataSourceID="ds" RenderStyle="Simple">
...
UPDATE BranchExtension SET [BranchExtension].[DefaultBranchLocation] = @P0 WHERE CompanyID = 2
public class BranchMaintExt : PXGraphExtension<BranchMaint>
{
    protected void BranchBAccount_BranchID_CommandPreparing(PXCache sender, PXCommandPreparingEventArgs e)
    {
        if ((e.Operation & PXDBOperation.Command) != PXDBOperation.Select && e.Table != typeof(BranchExtension))
        {
            e.Cancel = true;
        }
        else if ((e.Operation & PXDBOperation.Command) == PXDBOperation.Update && e.Value == null && e.Row != null)
        {
            decimal? ident = PXDatabase.SelectIdentity<PX.Objects.GL.Branch>(typeof(PX.Objects.GL.Branch.branchID).Name);
            if (ident != null && ident.Value > 0)
            {
                sender.SetValue<BranchBAccountExtension.branchID>(e.Row, Convert.ToInt32(ident));
                e.Value = ident;
            }
        }
    }

    protected void BranchBAccount_BAccountID_CommandPreparing(PXCache sender, PXCommandPreparingEventArgs e)
    {
        if (((e.Operation & PXDBOperation.Command) == PXDBOperation.Update)
            && sender.GetValue<BranchBAccountExtension.branchID>(e.Row) == null && e.Row != null)
        {
            decimal? ident = PXDatabase.SelectIdentity<PX.Objects.GL.Branch>(typeof(PX.Objects.GL.Branch.branchID).Name);
            if (ident != null && ident.Value > 0)
            {
                sender.SetValue<BranchBAccountExtension.branchID>(e.Row, Convert.ToInt32(ident));
            }
        }
    }
}

[PXTable(typeof(Branch.branchID), IsOptional = false)]
public class BranchExtension : PXCacheExtension<Branch>
{
    #region DefaultBranchLocation
    public abstract class defaultBranchLocation : IBqlField { }
    [PXDBInt()]
    [PXUIField(DisplayName = "Default Branch Location")]
    public virtual int? DefaultBranchLocation { get; set; }
    #endregion

    #region BAccountDefaultBranchLocation
    public abstract class bAccountDefaultBranchLocation : IBqlField { }
    [PXDBScalar(typeof(Search<BAccountExtension.bAccountDefaultBranchLocation, Where<BAccount.bAccountID, Equal<Branch.bAccountID>>>))]
    [PXInt()]
    [PXUIField(DisplayName = "Default Branch Location")]
    public virtual int? BAccountDefaultBranchLocation { get; set; }
    #endregion
}

[PXTable(typeof(BAccount.bAccountID), IsOptional = false)]
public class BAccountExtension : PXCacheExtension<BAccount>
{
    #region BAccountDefaultBranchLocation
    public abstract class bAccountDefaultBranchLocation : IBqlField { }

    [PXDBInt()]
    [PXUIField(DisplayName = "Default Branch Location")]
    public virtual int? BAccountDefaultBranchLocation { get; set; }
    #endregion
}

public class BranchBAccountExtension : PXCacheExtension<BranchMaint.BranchBAccount>
{
    #region BranchID
    public abstract class branchID : PX.Data.IBqlField
    {
    }
    [PXDBInt(BqlField = typeof(PX.Objects.GL.Branch.branchID))]
    [PXUIField(DisplayName = "Branch ID", Visibility = PXUIVisibility.Invisible)]
    public virtual int? BranchID { get; set; }

    #endregion

    #region DefaultBranchLocation
    public abstract class defaultBranchLocation : IBqlField { }
    [PXDBInt(BqlField = typeof(BranchExtension.defaultBranchLocation))]
    [PXUIField(DisplayName = "Default Branch Location")]
    public virtual int? DefaultBranchLocation { get; set; }
    #endregion

    #region BAccountDefaultBranchLocation
    public abstract class bAccountDefaultBranchLocation : IBqlField { }

    [PXDBInt]
    [PXUIField(DisplayName = "Default Branch Location")]
    public virtual int? BAccountDefaultBranchLocation { get; set; }
    #endregion
}