Parent fields empty On Add Row Subform in Edit mode

Parent fields empty On Add Row Subform in Edit mode

In my Invoice application I have parent form Invoice and a subform Invoice Lines. When a new line is added in the subform a script copies the unique id form the parent (Invoice) to the child (Invoice Line).

This works fine when I create a new Invoice. However when I edit the invoice and then add a line in the subform the reference is not copied. The script is triggered but it seems that the parent field (input.INVOICE_ID) is empty in edit mode.

Ivan