Stan A
Stan A

Reputation: 143

RowPersisted on two different DAC's are in infinite loop

I currently have custom RowPersisted events on SOLine and POLine in Acumatica. Basically I need to make sure that custom Vendor cost field in SO and unit price field in PO update each other for all the linked PO's and SO's, when user saves them in Acumatica. So I have something like this in POLine_RowPersisted:

        soRecExt.UsrVendorCost = line.CuryUnitCost;

        SOOrderEntry graph = PXGraph.CreateInstance<SOOrderEntry>();

        graph.CurrentDocument.Current = soOrd;
        var result = graph.Transactions.Select();

        graph.Transactions.Update(soRec);
        graph.Actions.PressSave();

And something like this in SOLine_RowPersisted:

        poRec.CuryUnitCost = lineExt.UsrVendorCost;

        POOrderEntry graph = PXGraph.CreateInstance<POOrderEntry>();

        graph.CurrentDocument.Current = poOrd;
        var result = graph.Transactions.Select();

        graph.Transactions.Update(poRec);
        graph.Actions.PressSave();

So unfortunately when one is updated the whole thing enters infinite loop. I have tried something like this:

        POOrderEntry_Extension graphExt = graph.GetExtension<POOrderEntry_Extension>();
        graphExt.RowPersisted.RemoveHandler<SOOrderEntry_Extension>(graphExt.POLine_RowPersisted);

However, there is no RowPersisted on graph extension. My events are set to public. Can someone help please?

Upvotes: 0

Views: 301

Answers (1)

Hugues Beaus&#233;jour
Hugues Beaus&#233;jour

Reputation: 8288

The events are registered and triggered by the Base graph so you have to remove them on base graph.

I believe what you're trying to accomplish is more along the lines of:

POOrderEntry_Extension graphExt = graph.GetExtension<POOrderEntry_Extension>();
graphExt.Base.RowPersisted.RemoveHandler<POOrderEntry>(graphExt.POLine_RowPersisted);

Where 'graph' is of type POOrderEntry then using 'graph' is equivalent to 'graphExt.Base'.

Upvotes: 0

Related Questions