如何在发布批次时在 GL301000 上启用自定义字段? [英] How to enable a custom field on GL301000 when the Batch is Posted?

查看:14
本文介绍了如何在发布批次时在 GL301000 上启用自定义字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I need to add a custom checkbox named "Cleared" to the detail lines in Acumatica's Journal Transactions page (GL301000). Users must be able to check this box after the batch is Posted. When the user checks the box another custom field titled "Date Cleared" should record the date and time. Both values must be saved in the database. Acumatica disables the detail lines after the batch is posted. How can I do this?

我看到了一个类似问题的答案 此处.JournalEntry BLC 似乎在 GetStateController 方法中使用 ReadOnlyStateController 而不是 CommonTypeStateController 来禁用细节行,所以我相信这个解决方案需要不同.此外,Journal Transactions 页面似乎不是由诸如 this 类似的问题.

I see an answer to a similar question here. The JournalEntry BLC seems to disable the detail lines using the ReadOnlyStateController rather than the CommonTypeStateController in the GetStateController method, so I believe this solution needs to be different. Also, the Journal Transactions page does not seem to be driven by automation steps like this similar question.

推荐答案

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

You are correct the Journal Transaction page is not driven by automation steps. If you want to enabled your custom Fields on the GLTran(lines) of this screen, you need to override both GLTran_RowSelected and Batch_RowSelected on your JournalEntry graph extension. Also, you can reuse the IsBatchReadonly function used on the GetStateController method.

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

On the Batch_RowSelected event handler you will:

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

-Check if batch is readOnly using the isBatchReadOnly function from the GetStateController method.
-Then, set allowUpdate to true on the caches.
-Set readonly false to all GLTran Fields
-Then set readonly true to all GLTran fields but your Custom Fields.

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

Then on the GLTran_RowSelected event handler you will setEnabled your Custom Fields.

参见下面的示例:

        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;
        }
    }

这篇关于如何在发布批次时在 GL301000 上启用自定义字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆