Help with a custom function-copying a date value

Help with a custom function-copying a date value

Hello:

I'm really struggling with the custom functions.  All I want to do is copy a date value from a deal record to the account record .  This value needs to be updated yearly with every sale.  After watching videos and trying lots and lots of examples, I just don't understand how to do it. Can someone please help?

The value in the deal is "Maintenance Expiration" (API = Maintenance_Expiration) and the value in the related account is "Support Expires" (API = Term_Expires).  Both are date fields.


dealid = dealid.toLong();
rec = zoho.crm.getRecordById("Deals",dealid);
resp = zoho.crm.getRelatedRecords("Accounts","Deals",dealid);
mp = Map();
mp.put("Term_Expires",ifnull(rec.get("Maintenance_Expiration"),"").toDate());
updateResp = zoho.crm.updateRecord("Accounts",dealid,mp);
info mp;
info updateResp;

Thank you.