Print

Zoho CRM: Schedule a Call using Deluge

What?
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;
  1.  // test to get the JSON response format 
  2.  r_CallDetails = zoho.crm.getRecordById("Calls",123456789012345678)
  3.  info r_CallDetails; 
  4.  // 
  5.  // system/application is set to EST (America/New_York) 
  6.  v_SystemCallTime = '2021-11-19 11:12:34'
  7.  // 
  8.  // manual setting to specify system/application offset 
  9.  v_ApplicationTimeOffset = "-05:00"
  10.  // 
  11.  // customer is in (America/Los_Angeles) 
  12.  v_CustomerCallTime = '2021-11-19 08:12:34'
  13.  // 
  14.  // set system/application date time start in CRM format 
  15.  v_SystemAppointmentDateTimeStart = v_SystemCallTime.toString("yyyy-MM-dd'T'HH:mm:00") + v_ApplicationTimeOffset; 
  16.  // 
  17.  // set system/application date time start in US format 
  18.  v_CustomerAppointmentDateTimeStart = v_CustomerCallTime.toString("MM/dd/yy h:mma z")
  19.  // 
  20.  // sample lead owner ID and lead ID record 
  21.  v_LeadOwnerID = 5432109876543210987
  22.  v_LeadID = 4321098765432109876
  23.  v_CustomerName = "Test User"
  24.  // 
  25.  // build map to schedule a call 
  26.  m_ScheduleCall = Map()
  27.  m_ScheduleCall.put("$se_module","Leads")
  28.  m_ScheduleCall.put("Owner",v_LeadOwnerID)
  29.  m_ScheduleCall.put("What_Id",v_LeadID)
  30.  m_ScheduleCall.put("Subject","Scheduled Call with " + v_CustomerName)
  31.  m_ScheduleCall.put("Call_Start_Time",v_SystemAppointmentDateTimeStart)
  32.  m_ScheduleCall.put("Call_Status","Scheduled")
  33.  m_ScheduleCall.put("Call_Type","Outbound")
  34.  // 
  35.  // optional fields 
  36.  m_ScheduleCall.put("Call_Purpose","Prospecting")
  37.  m_ScheduleCall.put("Call_Agenda","A scheduled call to phone " + v_CustomerName + " at their time of " + v_CustomerAppointmentDateTimeStart)
  38.  // 
  39.  // with a reminder 10 minutes before 
  40.  m_ScheduleCall.put("Reminder","10 mins")
  41.  // not sure if this does anything. hopefully notifies the staff user 
  42.  m_ScheduleCall.put("send_notification",true)
  43.  r_ScheduleCall = zoho.crm.createRecord("Calls", m_ScheduleCall)
  44.  info r_ScheduleCall; 

Error(s) Encountered:
Source(s):
Category: Zoho :: Article: 788