pricerc wrote:I feel like I might be missing something obvious...
When copying a quote, I can handle SalesOrder_Created and get the source quote to populate a S/O's custom fields.
How do I copy custom data to a credit note when creating one from a sales order?
When a credit note is created from a sales order, the CreditNoteInvoiceHistoryID and CreditNoteInvoiceID properties contains the values of the sales order you created the credit note from.
So, in a handler of the Created event, you can inspect the NewSalesOrderType parameter and if it is e_NewSalesOrderCreditNote, and the CreditNoteInvoiceHistoryID is not null or empty, then you know you're a credit note created from a sales order and the CreditNoteInvoiceID is the SO_Main.InvoiceID and the CreditNoteInvoiceHistoryID is the SO_History.InvoiceHistoryID of the sales order.
We don't have the whole sales order as a parameter to the Created event like we do with when making a sales order from a quote, unfortunately, but it will be easy enough to create a new sales order business logic instance and read that with the CreditNoteInvoiceID and find the snapshot with the matching CreditNoteInvoiceHistoryID.