Need a function to update a custom field in Deals upon deal creation based on custom field in associated Contact

Need a function to update a custom field in Deals upon deal creation based on custom field in associated Contact

Hello,

I have a custom field in my deals module that is a single select dropdown list.  I would like this field to be automatically upon new deal creation based on the value of a custom field in my Contacts module for the associated contact.

Example:  Contacts are either Self Generated or Company Provided in the Lead Source field for the Contact.  The deals created under this contact also have a Lead Source field which I would like to be updated based on the field in the Contact upon deal creation.  So, if a new deal is created, and the Contact lead source value is Self Generated, then I want the field value in the Deal for Lead Source to also be Self Generated, and vice versa.  Can anyone assist with a function for this?