【问题标题】:Can't set extended field to newly created object's Ref Nbr无法将扩展字段设置为新创建对象的 Ref Nbr
【发布时间】:2018-04-24 03:34:42
【问题描述】:

在“现金销售”页面上,我将覆盖释放按钮,为正在创建的记录创建第二个日记帐交易,该记录将根据屏幕上的某些信息对现金帐户进行调整。我的流程运行良好,成功创建了新的日记帐交易,但是当它在现金销售页面上设置扩展字段,然后执行释放按钮的基本操作时,我收到一条错误消息:

错误:处理字段资金批次值 GLHW016312 时出错 错误:系统中找不到资金批次“GLHW016312”。

执行流程的代码如下:

public delegate IEnumerable ReleaseDelegate(PXAdapter adapter);
[PXOverride]
public IEnumerable Release(PXAdapter adapter, ReleaseDelegate baseMethod)
{
    //Journal Transaction uses batch number
    if (Base.CurrentDocument.Current.ExtRefNbr != null && Base.CurrentDocument.Current.ExtRefNbr != string.Empty)
    {
        if (GLSetup.Current.GetExtension<GLSetupExt>().UsrCreateFundEntry == true)
        {
            if (CFBSAdjustments.Select().Count > 0)
            {
                Customer customer = PXSelect<Customer, Where<Customer.bAccountID, Equal<Current<Customer.bAccountID>>>>.Select(Base);
                JournalEntry graph = PXGraph.CreateInstance<JournalEntry>();
                Batch batch = graph.BatchModule.Insert();
                batch.Description = "Fund Entry for Cash Sales Reference " + Base.CurrentDocument.Current.RefNbr;
                decimal? debit = 0;
                decimal? credit = 0;
                foreach (CFBSCashSalesAdjustment row in CFBSAdjustments.Select())
                {
                    GLTran tran = graph.GLTranModuleBatNbr.Insert();
                    tran.AccountID = row.Account;
                    tran.SubID = row.Subaccount;
                    tran.DebitAmt = row.DebitAmt;
                    tran.CuryDebitAmt = row.DebitAmt;
                    debit += row.DebitAmt;
                    tran.CreditAmt = row.CreditAmt;
                    tran.CuryCreditAmt = row.CreditAmt;
                    credit += row.CreditAmt;
                    tran.RefNbr = row.CashSalesRefNbr;
                    tran.TranDesc = customer.AcctCD + " - " + customer.AcctName;
                    graph.GLTranModuleBatNbr.Update(tran);
                }

                batch.CreditTotal = credit;
                batch.CuryCreditTotal = credit;
                batch.DebitTotal = debit;
                batch.CuryDebitTotal = debit;
                batch = graph.BatchModule.Update(batch);
                graph.Actions.PressSave();

                if (GLSetup.Current.GetExtension<GLSetupExt>().UsrAutoRelease == true)
                {
                    graph.BatchModule.Current.Hold = false;
                    graph.release.Press();
                }

                Base.Document.Current.GetExtension<ARRegisterExt>().UsrFundBatch = batch.BatchNbr;
                Base.Actions.PressSave();
            }
        }
    }
    return baseMethod(adapter);
}

经过调试,发现错误发生在return baseMethod(adapter)这一行。

奇怪的是,如果我在错误上单击“确定”并再次单击“释放”,它将顺利通过,没有任何错误,创建两条记录,并将自定义记录设置为扩展字段。

首次发布,错误:

第二次发布,成功添加了标头的 ref nbr 链接:

从图片中可以看出,日志分录创建成功时的批号与错误不一样。它确实创建了两次记录。

对于扩展字段,我将其设置为选择器,启用 = false 并允许编辑 = true 以生成链接。

【问题讨论】:

    标签: acumatica


    【解决方案1】:

    如果用户从未直接填充您的扩展字段,您可以尝试删除选择器。或者尝试在选择器中指定ValidateValue = false

    【讨论】:

    • 我使用选择器的唯一原因是我可以直接链接到所见的记录。除了选择器之外,我还可以使用其他方法来创建指向记录的链接吗?
    • 做到了,非常感谢!我想我记得我需要一个完全不同的解决方案,只是忘记了选择器中的 ValidateValue = false 选项。
    猜你喜欢
    • 1970-01-01
    • 2020-06-26
    • 2020-06-26
    • 1970-01-01
    • 2018-06-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多