Updating custom field is ending into infinite loop

 ̄綄美尐妖づ 提交于 2019-12-02 08:13:54

When saving, APInvoice_RowUpdated modifies ARInvoice which in turn modifies APInvoice which triggers APInvoice_RowUpdated producing an infinite loop of event calls. The inverse in ARInvoice_RowUpdated which updates APInvoice will result in a similar infinite loop.

To get out of this, you can remove the graph event handler at runtime after instantiating the graph. First make your event handler access modifier public so you can reference them:

public virtual void APInvoice_RowUpdated(PXCache sender, PXRowUpdatedEventArgs e) 

After creating a graph, get the extension and remove the handler that cause the infinite loop:

APInvoiceEntry graph = PXGraph.CreateInstance<APInvoiceEntry>();
APInvoiceEntryExtension graphExt = graph.GetExtension<APInvoiceEntryExtension>();
graphExt.RowUpdated.RemoveHandler<APInvoice>(graphExt.APInvoice_RowUpdated);

The same modification has to be done for ARInvoice because the infinite loop goes both way, from AP to AR and from AR to AP.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!