首页 文章

如何在发布批处理时在GL301000上启用自定义字段?

提问于
浏览
0

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

我看到了类似问题的回答here . JournalEntry BLC似乎使用ReadOnlyStateController而不是GetStateController方法中的CommonTypeStateController禁用细节线,所以我认为这个解决方案需要不同 . 此外,期刊交易页面似乎不是由像this类似问题的自动化步骤驱动的 .

1 回答

  • 0

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

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

    • 检查是否只使用 GetStateController 方法中的 isBatchReadOnly 函数读取批次 .
    • 然后,在缓存上将allowUpdate设置为true .
    • 将readonly false设置为所有GLTran字段
    • 然后将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;
            }
        }
    

相关问题