Issue connecting all documents to the customer

I’m trying to connect every documents that are created to customer.
i come up with an idea, that, i created a table named ‘connected documents’ with 2 fields ‘Document Name’ and ‘Document ID’. And place a code snippet to add the document name and its id to the table ‘connected documents’.

The problem I’m having is, the field ‘Document ID’ is not a linking with the corresponding DocType. i cant use link for this, because the links are different for rows are different.

Can anyone help me to sort this issue.

Maybe you could use delivered Customer DocType and check how the connections work there?