Page 1 of 1

Subscribe to event for when invoice line item deleted ?

Posted: Mon Sep 10, 2018 1:21 pm
by toddsou
Hi-

I'd like to know when a user has removed a line item from an Invoice.
In that use case, we have some custom records regarding payments made against that line item that I need to adjust.

What options do I have for registering a handler or otherwise getting notified so I can execute some custom code?

Thanks!

Re: Subscribe to event for when invoice line item deleted ?

Posted: Tue Sep 11, 2018 12:05 pm
by BobRichards
Without knowing more, here are a couple general thoughts (that we use in conjunction sometimes):
  • Tuck some lines information in the Tags area for the invoice. It can allow you to determine if a line is added/removed.
  • Register for the "InvoiceChanged" notification. It will call your handler if user changes the invoice status (Sent, Quote,...).
  • Use the OrderSaving event and open the prior version of the order to do a compare.
  • Use the OrderSaved event and open the prior version of the order to do a compare.
  • Monitor each invoice collection in a Shell package.
Example of monitoring list changes:

Code: Select all

// Pseudo-code from memory of another dev!
invoice = invoice you want to monitor.
var invoiceLines = (IBindingList)invoice.GetProperty("Lines");
invoiceLines.ListChanged += MyHandler;

Re: Subscribe to event for when invoice line item deleted ?

Posted: Tue Sep 18, 2018 10:00 am
by toddsou
Ok, thanks for the tip, and the example code for monitoring list changes.

....and it looks like the ListChangedEventArgs param offers a ListChangedType property which can be compared against the ListChangedType .ItemDeleted enum value.

Looks promising.

Regards-