This is an article to document how to schedule a call with a reminder in Zoho CRM using Zoho Deluge.
Why?
Because I find a need to document anything that takes longer than 30 minutes to figure out so I don't spend so long the next time I have to do it. The use-case scenario here is that when an appointment is made for a Lead in a booking system, we want a task or call in CRM to popup and remind us that we need to phone this Lead.
How?
It sounds straightforward: schedule a call using the GUI then write a test function to check the JSON that is being returned for API names... If that were the case, it would have been a 5 minute job. Instead, it's turned into over an hour of figuring this out. So here's a working snippet of code:
copyraw
	
// test to get the JSON response format
r_CallDetails = zoho.crm.getRecordById("Calls",123456789012345678);
info r_CallDetails;
//
// system/application is set to EST (America/New_York)
v_SystemCallTime = '2021-11-19 11:12:34';
//
// manual setting to specify system/application offset
v_ApplicationTimeOffset = "-05:00";
//
// customer is in (America/Los_Angeles)
v_CustomerCallTime = '2021-11-19 08:12:34';
//
// set system/application date time start in CRM format
v_SystemAppointmentDateTimeStart = v_SystemCallTime.toString("yyyy-MM-dd'T'HH:mm:00") + v_ApplicationTimeOffset;
//
// set system/application date time start in US format
v_CustomerAppointmentDateTimeStart = v_CustomerCallTime.toString("MM/dd/yy h:mma z");
//
// sample lead owner ID and lead ID record
v_LeadOwnerID = 5432109876543210987;
v_LeadID = 4321098765432109876;
v_CustomerName = "Test User";
//
// build map to schedule a call
m_ScheduleCall = Map();
m_ScheduleCall.put("$se_module","Leads");
m_ScheduleCall.put("Owner",v_LeadOwnerID);
m_ScheduleCall.put("What_Id",v_LeadID);
m_ScheduleCall.put("Subject","Scheduled Call with " + v_CustomerName);
m_ScheduleCall.put("Call_Start_Time",v_SystemAppointmentDateTimeStart);
m_ScheduleCall.put("Call_Status","Scheduled");
m_ScheduleCall.put("Call_Type","Outbound");
//
// optional fields
m_ScheduleCall.put("Call_Purpose","Prospecting");
m_ScheduleCall.put("Call_Agenda","A scheduled call to phone " + v_CustomerName + " at their time of " + v_CustomerAppointmentDateTimeStart);
//
// with a reminder 10 minutes before
m_ScheduleCall.put("Reminder","10 mins");
// not sure if this does anything. hopefully notifies the staff user
m_ScheduleCall.put("send_notification",true);
r_ScheduleCall = zoho.crm.createRecord("Calls", m_ScheduleCall);
info r_ScheduleCall;
	- // test to get the JSON response format
 - r_CallDetails = zoho.crm.getRecordById("Calls",123456789012345678);
 - info r_CallDetails;
 - //
 - // system/application is set to EST (America/New_York)
 - v_SystemCallTime = '2021-11-19 11:12:34';
 - //
 - // manual setting to specify system/application offset
 - v_ApplicationTimeOffset = "-05:00";
 - //
 - // customer is in (America/Los_Angeles)
 - v_CustomerCallTime = '2021-11-19 08:12:34';
 - //
 - // set system/application date time start in CRM format
 - v_SystemAppointmentDateTimeStart = v_SystemCallTime.toString("yyyy-MM-dd'T'HH:mm:00") + v_ApplicationTimeOffset;
 - //
 - // set system/application date time start in US format
 - v_CustomerAppointmentDateTimeStart = v_CustomerCallTime.toString("MM/dd/yy h:mma z");
 - //
 - // sample lead owner ID and lead ID record
 - v_LeadOwnerID = 5432109876543210987;
 - v_LeadID = 4321098765432109876;
 - v_CustomerName = "Test User";
 - //
 - // build map to schedule a call
 - m_ScheduleCall = Map();
 - m_ScheduleCall.put("$se_module","Leads");
 - m_ScheduleCall.put("Owner",v_LeadOwnerID);
 - m_ScheduleCall.put("What_Id",v_LeadID);
 - m_ScheduleCall.put("Subject","Scheduled Call with " + v_CustomerName);
 - m_ScheduleCall.put("Call_Start_Time",v_SystemAppointmentDateTimeStart);
 - m_ScheduleCall.put("Call_Status","Scheduled");
 - m_ScheduleCall.put("Call_Type","Outbound");
 - //
 - // optional fields
 - m_ScheduleCall.put("Call_Purpose","Prospecting");
 - m_ScheduleCall.put("Call_Agenda","A scheduled call to phone " + v_CustomerName + " at their time of " + v_CustomerAppointmentDateTimeStart);
 - //
 - // with a reminder 10 minutes before
 - m_ScheduleCall.put("Reminder","10 mins");
 - // not sure if this does anything. hopefully notifies the staff user
 - m_ScheduleCall.put("send_notification",true);
 - r_ScheduleCall = zoho.crm.createRecord("Calls", m_ScheduleCall);
 - info r_ScheduleCall;
 
Error(s) Encountered:
{"code":"INVALID_DATA","details":{"expected_data_type":"datetime","api_name":"Call_Start_Time"},"message":"invalid data","status":"error"}
correct Call_Start_Time to CRM format of yyyy-MM-ddTHH:mm:ss-05:00 or have you mapped the field twice?{"code":"MANDATORY_NOT_FOUND","details":{"api_name":"Call_Type","json_path":"$.data[0].Call_Type"},"message":"Empty Call Type","status":"error"}
ok specify a call_type{"code":"INVALID_DATA","details":{"api_name":"Reminder"},"message":"invalid data","status":"error"}
trying to submit a CRM date time when it just wants the dropdown option equivalent (eg. "10 mins", "1 hrs")
Just as a refresher if this was a task and not a call:copyrawv_ReminderDate = v_SystemAppointmentDateTime.subMinutes(15); v_ReminderStr = "FREQ=NONE;ACTION=EMAILANDPOPUP;TRIGGER=DATE-TIME:" + v_ReminderDate.toString("yyyy-MM-dd'T'HH:mm:ss") + "-05:00"; m_ReminderAlarm = Map(); m_ReminderAlarm.put("ALARM",v_ReminderStr); m_CreateTask.put("Remind_At", m_ReminderAlarm);- v_ReminderDate = v_SystemAppointmentDateTime.subMinutes(15);
 - v_ReminderStr = "FREQ=NONE;ACTION=EMAILANDPOPUP;TRIGGER=DATE-TIME:" + v_ReminderDate.toString("yyyy-MM-dd'T'HH:mm:ss") + "-05:00";
 - m_ReminderAlarm = Map();
 - m_ReminderAlarm.put("ALARM",v_ReminderStr);
 - m_CreateTask.put("Remind_At", m_ReminderAlarm);
 
Source(s):
- Zoho CRM Tips: Schedule Calls to records
 - Zoho Community: Zoho CRM: Zoho Api v2 Log a Call to Contact Error - Call_Type Invalid Direction
 
Category: Zoho :: Article: 788
	

			     
						  
                
						  
                
						  
                
						  
                
						  
                

Add comment