0

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?

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.

1 Answers1

0

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.

On the Batch_RowSelected event handler you will:

-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.

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

See sample below:

        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;
        }
    }
cbetabeta
  • 605
  • 6
  • 11