Configure SMS/WhatsApp Logs on Record

Now, let’s configure SMS logs – a record of incoming and outgoing texts associated with a lead, contact or custom modules with below configuration

Configure SMS/WhatsApp Logs as Related list on Lead Module

  1. Open any lead record detail view and click on add a new related list at the bottom
  2. Now choose “Functions” to add contextual SMS records related to lead
  3. Create a new function
  4. Give any name for the function, display name, and description
  5. Paste below code in code editor
record = zoho.crm.getRecordById("Leads",lid.toLong()); phone = record.getJSON("Phone"); phone = encodeUrl(phone); data1 = invokeurl [ url :"https://app.crm-messaging.cloud/index.php/Zoho/recordTest?phone=" + phone + "&token=" + token type :GET ]; data = "<record>"; data = data + "<row no='0'><FL value='From'>From</FL><FL value='To'>To</FL><FL value='MSG'>MSG</FL><FL value='Log'>Log</FL><FL value='Date'>Date</FL></row>"; i = 1; for each newdata in data1 { data = data + "<row no='" + i + "'><FL value='From'>" + newdata.getJSON("from") + "</FL><FL value='To'>" + newdata.getJSON("to") + "</FL><FL value='MSG'>" + newdata.getJSON("msg") + "</FL><FL value='Log'>" + newdata.getJSON("log") + "</FL><FL value='Date'>" + newdata.getJSON("date") + "</FL></row>"; i = i + 1; } return data + "</record>";

6. Click on Edit Arguments and map lid with lead id and token with

Zoho token in CRM Variables as shown below.

sms logs on leads

 7. Click Save and Save your related list by giving a name like SMS logs

You will now get all SMS logs in the related list mapped on each lead.

Configure SMS Logs as a Related list on Contact Module

  1. Open any Contact record detail view and click on add a new related list at the bottom
  2. Now choose “Functions” to add contextual SMS records related to contact
  3. Create a new function
  4. Give any name for the function, display name, and description
  5. Paste the below code in the code editor
record = zoho.crm.getRecordById("Contacts",lid.toLong()); phone = record.getJSON("Phone"); phone = encodeUrl(phone); data1 = invokeurl [ url :"https://app.crm-messaging.cloud/index.php/Zoho/recordTest?phone=" + phone + "&token=" + token type :GET ]; data = "<record>"; data = data + "<row no='0'><FL value='From'>From</FL><FL value='To'>To</FL><FL value='MSG'>MSG</FL><FL value='Log'>Log</FL><FL value='Date'>Date</FL></row>"; i = 1; for each newdata in data1 { data = data + "<row no='" + i + "'><FL value='From'>" + newdata.getJSON("from") + "</FL><FL value='To'>" + newdata.getJSON("to") + "</FL><FL value='MSG'>" + newdata.getJSON("msg") + "</FL><FL value='Log'>" + newdata.getJSON("log") + "</FL><FL value='Date'>" + newdata.getJSON("date") + "</FL></row>"; i = i + 1; } return data + "</record>";

6. Click on Edit Arguments and map lid with contact id and token with zoho token stored in CRM Variables as shown below.

sms logs on contact

 7. Click Save and Save your related list by giving a name like SMS logs

You will now get all SMS logs in the related list mapped on each contact.

For setting up Send SMS and Bulk SMS Buttons on different fields and modules, use the below code.

Go to Settings => Links & Buttons => Choose your module =>New Button => Name your button => Place your button => Choose Writing Functions as action

and name your function and add below code in code editor

getSettings = invokeurl
[
url :"https://app.crm-messaging.cloud/index.php/Zoho/getConfiguration?token=" + token
type :GET
];
settings = getSettings.getJSON("config");
record = zoho.crm.getRecordById("Leads",cid.toLong());
if(settings == "phone" || settings == "")
{
phone = record.getJSON("Phone");
if(phone == "" || phone == null)
{
phone = record.getJSON("Mobile");
}
}
else if(settings == "mobile")
{
phone = record.getJSON("Mobile");
if(phone == "" || phone == null)
{
phone = record.getJSON("Phone");
}
}
else
{
phone = record.getJSON("");
}
phone = encodeUrl(phone);
uri = "https://app.crm-messaging.cloud/index.php/Zoho/smsSend?phone=" + phone + "&orgid=" + orgId;
openUrl(uri,"new window");
return "";

Make sure to replace Leads with your custom module and with the field name where you store your mobile number.

For more such customizations, drop an email to [email protected] or take our consultancy service Zoho Consulting Quote – CRM Messaging (crm-messaging.cloud)