Fill fields in an account, based on parent account

Fill fields in an account, based on parent account

Hello,

We have a number of accounts in our system, some of these accounts are 'child accounts' to other accounts in the system. The child account should have the same address as the parent account.

I have created a rule that executes on 'Field Update' - the field is a 'Lookup' field that searches for Accounts and is called 'Parent Account'

However, I am not sure what the custom function code should be to find the address details of the 'Parent Account' and then map these to the account that the 'Lookup' field has been updated on.

Any help is much appreciated, so far I have the below but I am assuming this isnt working because it doesn't know where to pull the address from;
  1. orgIdStr=input.orgId.toString();
  2. accountDetails = zoho.crm.getRecordById(("Accounts"),input.orgId);
  3. AddressLine1=ifnull((accountDetails).get("Address Line 1"),"");
  4. AddressLine2=ifnull((accountDetails).get("Address Line 2"),"");
  5. AddressLine3=ifnull((accountDetails).get("Address Line 3"),"");
  6. Town=ifnull((accountDetails).get("Town"),"");
  7. County=ifnull((accountDetails).get("County"),"");
  8. Postcode=ifnull((accountDetails).get("Postcode"),"");
  9. mp=map();
  10. mp.put("Address Line 1",AddressLine1);
  11. mp.put("Address Line 2",AddressLine2);
  12. mp.put("Address Line 3",AddressLine3);
  13. mp.put("Town",Town);
  14. mp.put("County",County);
  15. mp.put("Postcode",Postcode);
  16. updateResp = zoho.crm.updateRecord(("Accounts"),orgIdStr,mp);