Contents tagged with Transaction

  • How to override the Persist method properly

    Hello everybody,

    today I want to write a few words on how to override persist method of Acumatica properly. When I say properly I mean not save just some fragment of data, but use transaction like approach.

    In other words how to achieve all or noghint during persisting.

    Quite often I see template like this:

    public void Method1()

    {

        //normal flow

    }

    string message = "Forbidden to do anything at 18 hour";

    public void Method2()

    {

        if (DateTime.Now.Hour == 18)

        {

            throw new PXException(message);

        }

    }

    public void RollBackMethod1AndMethod2()

    {

    }

    [PXOverride]

    public void Persist(Action del)

    {

        try

        {

            del();

            Method1(); … more