Script to populate lookup field to custom module record back the lead it was based off

Script to populate lookup field to custom module record back the lead it was based off

Hello,

I have the below code which currently creates a new record in a custom module when a new lead is created. This works great, however I cannot get the record to link back to the lead.

void Create_building_from_name(String Address1,Int inhabitant_id,String lead_name,String Address2,String Address3,String Postcode,String City)

// Inhabitant_ID is the lead ID and and lead_name is Last Name
  1. inhabitant_record = zoho.crm.getRecordById("Leads",inhabitant_id);
  2. info inhabitant_record;
  3. inhabitantFirstName = inhabitant_record.get("First_Name");
  4. inhabitantLastName = inhabitant_record.get("Last_Name");
  5. building_map = Map();
    1. building_map.put("Name",Address1);
    2. building_map.put("Address_1",Address1);
    3. building_map.put("Address_2",Address2);
    4. building_map.put("Address_3",Address3);
    5. building_map.put("Postcode",Postcode);
    6. building_map.put("Current_Tenant_Name",inhabitantFirstName + " " + inhabitantLastName);
    7. building_map.put("City",City);

  6. create_building = zoho.crm.create("Buildings",building_map);
  7. info create_building;
  8. info building_map;
Can anyone please help me determine how to have a working lookup?

Also is there a way to maintain this connection when the lead is converted to an account?

Thanks