Skip to content

Instantly share code, notes, and snippets.

@jeznag
Created October 24, 2021 22:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeznag/53daf8ee6cba338a31a3d5240fc057a4 to your computer and use it in GitHub Desktop.
Save jeznag/53daf8ee6cba338a31a3d5240fc057a4 to your computer and use it in GitHub Desktop.
Add notes to Zoho CRM lead/contact when an SMS is received or sent
sms_record = zoho.crm.getRecordById("twiliosmsextension0__Sent_SMS", sms_record_id);
if (sms_record.get("Message_Type").startsWith("out")) {
note_title = "Outbound SMS";
note_content = "Outbound SMS sent by " + sms_record.get("Owner").get("name") + ": " + sms_record.get("Message");
} else {
note_title = "Inbound SMS";
note_content = "Inbound SMS received: " + sms_record.get("Message");
}
if (sms_record.get("LeadName") != null) {
record_id = sms_record.get("LeadName").get("id");
module_name = "Leads";
} else if (sms_record.get("ContactName") != null) {
record_id = sms_record.get("ContactName").get("id");
module_name = "Contacts";
} else if (sms_record.get("twiliosmsextension0__DealName") != null) {
record_id = sms_record.get("twiliosmsextension0__DealName").get("id");
module_name = "Deals";
}
notesMap = {
"Parent_Id": record_id,
"Note_Title": note_title,
"Note_Content": note_content,
"$se_module": module_name
};
response = zoho.crm.createRecord("Notes", notesMap);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment