I've tried to follow these steps and make it work for the accounts module which is supposed to be easier :
I've put the following code in a custom function but couldn't make it work properly :
accountinfo = zoho.crm.getRecordById("Accounts",cid.toLong());
relatedaccount = zoho.crm.getRelatedRecords("id","Accounts",cid.toLong(),1);
info = "id";
acctid = ifnull(accountinfo.get("Account_Name"),"").get("id");
info = acctid;
customerid = zoho.books.getRecords("Contacts","XXXX","zcrm_account_id=" + acctid).get("contacts").get(0).get("contact_id");
mp = Map();
mp.put("customer_id",customerid);
mp.put("date",today);
mp.put("zcrm_potential_id",cid);
create = zoho.books.createRecord("Estimates","XXXX",mp);
info create;
return "success";