Trying to update one record from another

Trying to update one record from another

I am using a custom function and going out of my mind - I just don't know why such an ordinary function is so hard and there should be a standard way of doing this 

I need to get the data from a field in a related record and put it into the same record in another one. In this case for a particular client they want to be able to update Lead filed with the phone number and email address from a contact where the person is already in the CRM

lead=input.leadID.toString();
contact=input.contactID.toString();
contactDetails = zoho.crm.getRelatedRecords("Contacts",lead,contact);
mp = map();
mp.put("Details","John");

This works and the problem seems to be the next bit

mp.put("Email",contactDetails.get("Email"),""));