I’ve written an AL Extension that clones / copies an invoice from Posted Sales Invoices to Sales Invoices (Unposted) using Record.TransferFields. At the same time it edits a description in a Comment line within the invoice. This works fine, but when I try to post the invoice in question, it reports an error stating that fields ‘Qty. To Invoice’ & ‘Qty.To Ship’ should contain a value that appears to be the same as field Quantity. (i.e. If Quantity = 4, then it complains that the aforementioned Qty fields are not also set to 4.
On investigation, fields ‘Qty. To Invoice’ & ‘Qty.To Ship’ do not exist in the posted table (Sales Invoice Line) but do in the unposted table (Sales Line) . This, I guess, explains why Record.TransferFields doesn’t put a value in these 2 fields because there’s no source.
So, I wrote an extra procedure to pass through the lines and copy the value in Quantity to ‘Qty. To Invoice’ & ‘Qty.To Ship’. This changed the error to ‘You cannot post these lines because you have not entered a quantity on one or more of the lines’.
There is a comment line that does not contain a quantity value because it is a comment (stating the obvious). The whole purpose of the extension is to copy a posted invoice to unposted and change the comment.
Did I do the right thing in copying the value(s) from Quantity to ‘Qty. To Invoice’ & ‘Qty.To Ship’?
Is it valid for an invoice to contain a Comment line having no Quantity?
Any other help would be welcome.