Event of Create New Document From POP-UP (Advance Coding)

Hi,

I have tow Doctypes X and Y
X has child-table, one of the child-table fields, its type is a link from Y,
Now I would like to create Y Document from the child-table.
same time there is a link field from X in Y.
Now, when creating Y from X child-table, I would like to set the X field default.

Please see the below picture.

Thank you in advance