Hi. I'm trying to streamline the user experience by creating a button that will generate a specific Deal (we have multiple Deal page layouts) and pre-populate it with Contact record information and static text.
It works but only if I run the function independently. Whenever I try to map the function to a button, it stops working.
My best guess is the function calling within the button looks for a String and I need to pass the Contact ID as an integer.
//contId == Contacts -> Contact ID
contDetails = zoho.crm.getRecordById("Contacts",contId.toLong());
//generate Opp name
dealType = "[CUSTOM NAME]";
acctName = ifnull(contDetails.get("Account_Name").get("name"),contDetails.get("Full_Name"));
//contName = ifnull(contDetails.get("Full_Name"),"");
dealName = dealType + " - " + acctName;
mp = Map();
mp.put("Deal_Name",dealName);
mp.put("Owner",ifnull(contDetails.get("Owner"),"").get("id"));
mp.put("Contact_Name",contId);
mp.put("Account_Name",ifnull(contDetails.get("Account_Name"),"").get("id"));
mp.put("Title",ifnull(contDetails.get("Title"),""));
mp.put("Email",ifnull(contDetails.get("Email"),""));
mp.put("Phone",ifnull(contDetails.get("Phone"),""));
mp.put("Mobile",ifnull(contDetails.get("Mobile"),""));
mp.put("Lead_Source",ifnull(contDetails.get("Lead_Source"),""));
mp.put("Email_Opt_Out",ifnull(contDetails.get("Email_Opt_Out"),""));
mp.put("Website",ifnull(contDetails.get("Website"),""));
mp.put("Mailing_Street",ifnull(contDetails.get("Mailing_Street"),""));
mp.put("Mailing_City",ifnull(contDetails.get("Mailing_City"),""));
mp.put("Mailing_State",ifnull(contDetails.get("Mailing_State"),""));
mp.put("Mailing_Zip",ifnull(contDetails.get("Mailing_Zip"),""));
mp.put("Mailing_Country",ifnull(contDetails.get("Mailing_Country"),""));
mp.put("Description",ifnull(contDetails.get("Description"),""));
mp.put("Stage","Prospect");
//create default Closing date for end of next month
mp.put("Closing_Date",today.eomonth(1));
//pass Product-Specific layout as part of the .put
mp.put("Layout",4622861000000522001);
create = zoho.crm.createRecord("Deals",mp);
info create;
TaskDetails = zoho.crm.getRelatedRecords("Tasks","Contacts",contId.toLong());
for each task in TaskDetails
{
taskmap = Map();
taskmap.put("What_Id",create.get("id"));
taskmap.put("$se_module","Deals");
updatetask = zoho.crm.updateRecord("Tasks",task.get("id"),taskmap);
info updatetask;
}
EventDetails = zoho.crm.getRelatedRecords("Events","Contacts",contId.toLong());
for each events in EventDetails
{
eventmap = Map();
eventmap.put("What_Id",create.get("id"));
eventmap.put("$se_module","Deals");
updateevent = zoho.crm.updateRecord("Events",events.get("id"),eventmap);
info updateevent;
}
CallDetails = zoho.crm.getRelatedRecords("Calls","Contacts",contId.toLong());
for each call in CallDetails
{
callmap = Map();
callmap.put("What_Id",create.get("id"));
callmap.put("$se_module","Deals");
updatecall = zoho.crm.updateRecord("Calls",call.get("id"),callmap);
info updatecall;
}