Why does a UDF in work table which should be null has value of other record?

Hi all, 

I hope you are up for some puzzles, I've spent 2 hours and I'm now lost.  The version is Sage 100 Advanced 2015, 5.20.1

We have a UDF in SO_InvoiceWrk.  The purpose of it is to grab the invoice number to which a credit memo will apply and shows on the printed credit memo.  Its data source is ApplyToInvoiceNo in SO_InvoiceHeader,   

The issue happens when a credit memo in a batch has the empty ApplyToInvoice field while any one of preceding credit memo has a value in the  ApplyToInvoice field.   Below shows you what happens, but basically the printed credit memo whose UDF should be nothing/null somehow gets the value of the preceding credit memo.  The UDF is multi-line at max length of 7, and other than the Uppercase display attribute and Caption, no other attributes are set, no validation, no other data sources. 

InvoiceNo ApplyToInvoice (SO_InvoiceHeaderl) UDF_ApplyToInvoice (SO_InvoiceWrk) Expected

UDF_ApplyToInvoice (So_InvoiceWrk)  Actual

1000-CM 10 10 10
1001-CM NULL NULL 10
1002-CM NULL NULL 10
1003-CM 11 11 11
1004-CM NULL NULL 11
1005-CM NULL NULL 11
1006-CM 23 23 23

What could be going on???  

Edit-2/23:  Added 4 more rows in the table above.  The data (shortened for convenience) are confirmed in DFDM.  Both files SO_InvoiceHeader and SO_InvoiceWrk show what's shown in the table.   

-ken