简体   繁体   English

在Acumatica中自动生成编号

[英]Auto Generate Number in Acumatica

I want to create an auto generate number which similar with auto increment for segment ID in Lot/Serial Classes, like in this picture. 我想创建一个自动生成的编号,该编号与批次/序列类中的段ID的自动递增类似,如图所示。

Lot/Serial Classes 批次/系列

After I check the code, I notice that it uses PXLineNbr 检查代码后,我注意到它使用了PXLineNbr

    public abstract class segmentID : PX.Data.IBqlField
    {
    }
    protected Int16? _SegmentID;
    [PXDBShort(IsKey = true)]
    [PXUIField(DisplayName="Segment Number", Enabled=false)]
    [PXLineNbr(typeof(INLotSerClass))]
    [PXDefault()]
    public virtual Int16? SegmentID
    {
        get
        {
            return this._SegmentID;
        }
        set
        {
            this._SegmentID = value;
        }
    }

After I try and apply it in my code, the auto generated number doesn't appear. 在尝试将其应用到我的代码中之后,自动生成的号码没有出现。 So I was wandering if I miss something else. 因此,如果我想念其他东西,我会在流浪。 Thank you in advance 先感谢您

Have you checked Example 7.1: Numbering Detail Data Records in the T200 training available at Acumatica Open University ? 您是否已在Acumatica Open UniversityT200培训中检查了示例7.1:对详细数据记录进行编号 It explains in detail, how the PXLineNbr attribute should be used to automatically number detail data records. 它详细说明了如何使用PXLineNbr属性自动对明细数据记录进行编号。

The pattern I'm using for PXLineNbr is to declare a line number counter field in the master table and a line number field in the detail table. 我用于PXLineNbr的模式是在主表中声明一个行号计数器字段,在明细表中声明一个行号字段。 It's simple and it works. 这很简单,而且可以正常工作。 LineNbr value is computed automatically from the counter by PXLineNbr attribute. LineNbr值是通过PXLineNbr属性从计数器自动计算得出的。

The LineCntr field: LineCntr字段:

public class MasterDAC : IBqlTable
{
    #region LineCntr
    public abstract class LineCntr : IBqlField { }

    [PXDBInt]
    [PXDefault(0)]
    public virtual int? LineCntr { get; set; }
    #endregion
}

The LineNbr field: LineNbr字段:

public class DetailDAC : IBqlTable
{
    #region LineNbr
    public abstract class lineNbr : IBqlField { }

    [PXDBInt(IsKey = true)]
    [PXDefault]
    [PXLineNbr(typeof(MasterDAC.LineCntr))]
    public virtual int? LineNbr { get; set; }
    #endregion
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM