Fetch Values using a Dynamic Link on Child Table

Anyone knows how to fetch data on a parent doctype and encode it on the child table using a dynamic link.

I was trying to fetch the data on a custom field on the parent doctype of the Sales Invoice then encode it on the child table payment entry references.

This is same on how the Supplier Invoice No. works. When the dynamic link is a Purchase Invoice, a supplier invoice no. field will be visible.