Display Related Modules Record in Detail View Record

Two Modules Accounts and Contacts.

In Accounts I created a field called Primary Contact.

In the detailview of Accounts I want Primary Contact to populate with the related contact that is marked as primary.

I have a field in Contacts that is a checkbox to mark it as Primary Contact.

How and Where do I write the code to retrieve the primary contact and display in a textarea field in Accounts?

Here is a sample:

https://community.sugarcrm.com/thread/24830

Hope it gives you some ideas.

Thanks,

AlxGr