Assuming that you need that PO information for invoices, know that the
customerref field is already part of the query at line 82 in the
4.14.1 version of the
PrintCustTrans file, so you should be able to [re]use the data from that query instead?
However, the customerref field is
not in the credit notes query at line 159. Assuming that you would want the same info for credit notes, it shouldn't be too much to add salesorders as a LEFT JOIN since the debtortrans table is already in this query to get the
customerref info. Then the field would be available for both situations.