Hi Cu07020542-00,
As Martin rightly mentioned, it is a strange business requirement. This requirement can be addressed through standard D365 FO (considering the screen clip that you shared is a Sales Order screen).
Anyways, if it is a custom link that you are creating then you can follow the approach mentioned below.
1. On the clicked event you can add the following snippet to retrieve the calling data source.
Other Alternatives:
Alternative Number 1:
1. You can alternatively extend the doResearch() method from DocuView and there is a sample snippet available under DocuView_PersonnelManagement_Extension.
Alternative Number 2:
1. You can leverage the below mentioned standard method available under DocuView form.
Alternative Number 3:
Alternatively, you can also consider the following:
1. Add a relation to the DocuRef table in the SalesTable.
SalesTable.DataAreaId == DocuRef.RefCompanyId
SalesTable.TableId == DocuRef.TableId
SalesTable.RecId == DocuRef.SalesRefRecId
2. Next, you can add the following code to the OnInitialized method of DocuView.
Hope this helps. Happy to answer questions, if any.