Entity Listener not Modified

Hi guys. I have an entity “Invoices” which has a one-to-many association of “InvoiceLines”.

If I go into “Edit Invoice” screen and modify the InvoiceLines (which i have set up as a table within the invoice edit screen) the invoice is not flagged as modified and does not run the listener I have which calculates the invoices total.

e.g. I have the following two invoiceLines:

QTY RATE TOTAL
1 10 10
2 20 40

And when I delete one from within the invoice editor i want the invoice total to change. But the problem is that when I delete (or add) etc the invoice is not flagged as modified and it does not run the invoice listener…

Is there a way around this?

Basically if anything changes with any invoiceLines i need to recalculate the invoice totals etc.

Hope it makes sense.

Hi Daryn,

I would suggest adding an entity listener to the InvoiceLines entity. It’s the only reliable option, because in theory InvoiceLines could be modified not only in the Invoice editor screen but in some business logic.

You will have to get a linked Invoice instance from InvoiceLines coming to the listener. It can be a detached instance, so merge it to save changes in it. See an example of such listener here.