The 7.7 release announcement mentions a User Interface improvement of:
When linking records via the Contacts subpanel in the Cases record view, the Search and Add Contacts drawer will automatically be filtered to only display contact records associated to the case's parent account.
I have been wanting to accomplish a similar behavior in the Accounts module. We have a one-to-one relationship between Accounts and Contacts to specify the primary contact for the account. When the user opens a lookup search to select a Contact I would like a filter automatically applied to only show contacts linked to that account. Can anyone point me in the right direction on how to accomplish this. I have tried searching the code base that is accomplishing the automatic filtering of the Contacts subpanel in the Cases record view but can't find seem to find the files that are doing this.