Search code examples
acumatica

Overwriting internal static class CATranDetailHelper funtion OnCATranDetailRowUpdatingEvent


Is there a way to extend/overwite the OnCATranDetailRowUpdatingEvent function that Is in the internal static class CATranDetailHelper?

enter image description here

Normally I can do something like this:

namespace test
{

    [PXProtectedAccess]
    
    public static class CATranDetailHelper_Extension : PXGraphExtension<CATranDetailHelper>
    {
        #region Event Handlers

        protected void CAEntryType_RowUpdating(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected InvokeBaseHandler)
        {
            //if (InvokeBaseHandler != null)
            //    InvokeBaseHandler(cache, e);
            var row = (CABankTranDetail)e.Row;

        }

        #endregion
    }

}

The problem being this is a static class. any advice of to overwrite this function will be appreciated


Solution

  • Is there a way to extend/overwite the OnCATranDetailRowUpdatingEvent function that Is in the internal static class CATranDetailHelper?

    No

    Normally I can do something like this: class PXGraphExtension< CATranDetailHelper >

    You can only create graph extension on classes that inherits from PXGraph class.

    Example:

    class SOOrderEntry : PXGraph<SOOrderEntry, SOOrder>

    Class CATranDetailHelper does not inherit from PXGraph so it can't be extended with PXGraphExtension.

    The problem being this is a static class. any advice of to overwrite this function will be appreciated

    The other problem is that the class is marked as internal. This indicates that this area of source code is off limit to customization and therefore you should not attempt to change it in any way.

    If you need to change the behavior you need to check where this method is called. Ideally the methods calls are in event handlers which you can replace by creating a graph extension.

    For example, there's a call to OnCATranDetailRowUpdatingEvent in CATranEntry graph. Since CATranEntry is a graph, you can create a graph extension on CATranEntry and replace the CASplit_RowUpdating event handler which ultimately calls OnCATranDetailRowUpdatingEvent.

    public class CATranEntry : PXGraph<CATranEntry, CAAdj>, PX.Objects.GL.IVoucherEntry
    {
        protected virtual void CASplit_RowUpdating(PXCache sender, PXRowUpdatingEventArgs e)
        {
            CATranDetailHelper.OnCATranDetailRowUpdatingEvent(sender, e);
            if (CATranDetailHelper.VerifyOffsetCashAccount(sender, e.NewRow as CASplit, CAAdjRecords.Current?.CashAccountID))
            {
                e.Cancel = true;
            }
            sender.SetValueExt<CASplit.curyTranAmt>(e.NewRow, (e.NewRow as CASplit).CuryTranAmt);
        }
    }