【问题标题】:How to enable a custom field on GL301000 when the Batch is Posted?批量过帐时如何在 GL301000 上启用自定义字段?
【发布时间】:2017-10-27 04:35:29
【问题描述】:

我需要在 Acumatica 的日记帐交易页面 (GL301000) 的详细信息行中添加一个名为“已清除”的自定义复选框。批次过帐后,用户必须能够选中此框。当用户选中该框时,另一个名为“清除日期”的自定义字段应记录日期和时间。这两个值都必须保存在数据库中。 Acumatica 在批次过帐后禁用明细行。我该怎么做?

我看到了类似问题here 的答案。 JournalEntry BLC 似乎使用 ReadOnlyStateController 而不是 GetStateController 方法中的 CommonTypeStateController 禁用了详细信息行,所以我相信这个解决方案需要有所不同。此外,Journal Transactions 页面似乎不是由 this 类似问题之类的自​​动化步骤驱动的。

【问题讨论】:

    标签: acumatica


    【解决方案1】:

    您是正确的,日记帐交易页面不是由自动化步骤驱动的。 如果要在此屏幕的 GLTran(lines) 上启用自定义字段,则需要在 JournalEntry 图形扩展上覆盖 GLTran_RowSelected 和 Batch_RowSelected。此外,您可以重用 GetStateController 方法中使用的 IsBatchReadonly 函数。

    Batch_RowSelected 事件处理程序上,您将:

    -使用 GetStateController 方法中的 isBatchReadOnly 函数检查批处理是否为只读。
    - 然后,在缓存中将 allowUpdate 设置为 true。
    - 将所有 GLTran 字段设置为 readonly false
    - 然后将 readonly 设置为所有 GLTran 字段,但您的自定义字段除外。

    然后在 GLTran_RowSelected 事件处理程序上,您将设置启用您的自定义字段。

    请参阅下面的示例:

            public class JournalEntry_Extension : PXGraphExtension<JournalEntry>
            {    
                protected void GLTran_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected del)
                {
                    GLTran row = (GLTran)e.Row;
    
                    if (del != null)
                        del(cache, e);
    
                    if (row != null)
                    {
                        PXUIFieldAttribute.SetEnabled<GLTranExt.usrCustomField1>(cache, row, true);
                        PXUIFieldAttribute.SetEnabled<GLTranExt.usrCustomField2>(cache, row, true);
                    }
                }
    
    
                protected void Batch_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected del)
                {
                    Batch row = (Batch)e.Row;
                    if (del != null)
                        del(cache, e);
    
                    if (row != null)
                    {
                        if (IsBatchReadonly(row))
                        {
                            //Set Cache Allow Update
                            cache.AllowUpdate = true;
                            Base.GLTranModuleBatNbr.Cache.AllowUpdate = true;
                            //First Set ReadOnly false to all fields
                             PXUIFieldAttribute.SetReadOnly(Base.GLTranModuleBatNbr.Cache, null, false);
    
    
                            //Then Set ReadOnly true to all fields but your custom ones
                            PXUIFieldAttribute.SetReadOnly<GLTran.accountID>(Base.GLTranModuleBatNbr.Cache, null, true);
                            PXUIFieldAttribute.SetReadOnly<GLTran.subID>(Base.GLTranModuleBatNbr.Cache, null, true);
                            .......
    
                        }
    
                    }
                }
    
            //Function used on the GetStateController method  
            private bool IsBatchReadonly(Batch batch)
            {
                return (batch.Module != GL.BatchModule.GL && Base.BatchModule.Cache.GetStatus(batch) == PXEntryStatus.Inserted)
                       || batch.Voided == true || batch.Released == true;
            }
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-24
      • 1970-01-01
      • 2021-07-08
      • 1970-01-01
      • 1970-01-01
      • 2017-12-30
      相关资源
      最近更新 更多