SMS Magic Interact for Zoho CRM

This integration streamlines your communication efforts, allowing you to engage w... Read more

Module Lookup on SMS History

Incoming and Outgoing messages in SMS History get associated with a relevant Lead/Contact record for which the mobile number of the recipient matches. 

Notes:
If multiple Lead or Contact records have the same Mobile Number, there can be discrepancies in the association of Lead/Contact.

To associate SMS History records with a relevant Custom Module record, you can configure Custom Module Lookup on SMS History. Follow the steps below to configure Lookup for your required Custom Modules -

  1. Create Lookup Field in SMS History Module layout

Create a Lookup field in SMS History for the custom module you wish to associate relevant SMS History records with. For the Deals module, we will create a lookup field - “Deal” in the standard layout of the SMS History module. 

  • Click on Setup > Customization > Modules and Fields

  • Click on SMS History

  • On Layouts tab, click on Standard

  • Drag and Drop LookUp from the Left Panel to the SMS History Information Layout

  • Enter Field Label as ‘Deal’

  • Select Lookup Module as ‘Deals’ from dropdown

  • Enter ‘SMS Deal History’ as the Related List Title

  • Click on the Done button

Notes:
Make sure the API name for the lookup field is the same as lookup field name. To check the API Name of the lookup field, Click on Setup > Developer Space > APIs > API Names tab > SMS History.

  1. Create Workflow that will perform the Lookup for the Custom Module.

Follow the below steps to create a Workflow Automation -

  • Click on Setup > Automation > Workflow Rules

  • Click on + Create Rule

  • Select the Module SMS History.

  • Enter a Rule Name and Description for the Custom Module for which you are creating the Lookup Workflow

  • Click on the Next button

  1. Create a Workflow rule as shown in screenshot below -

    • WHEN - On a Record Action > Select Create

    • CONDITION - All SMS History

    • ACTION - Function > Write your own

  1. Continue Creating a function with the steps below -

    • Enter Function Name - AssociateDeals i.e Associate<Custom_Module_Name>

    • Enter Display Name - Associate Deals i.e Associate <Custom_Module_Name>

    • Enter a Description(optional)

    • Click on the Next button

    • Copy and paste the below code in the Text Area

MODULE_TO_BE_UPDATED = “smsmagic4__SMS_History”;
LOOKUP_MODULE = “Deals”;
LOOKUP_FIELD = “Deal”;
PHONE_FIELD = “Mobile”;
phone_list = {mobile_number,mobile_number.subString(1),mobile_number.subString(2),mobile_number.subString(3), mobile_number.subString(4)};
record_id = “”;
is_record_found = False;
for each  mobile in phone_list
{
  response = zoho.crm.searchRecords(LOOKUP_MODULE,”(“+PHONE_FIELD+”:equals:”+mobile + “)”);
  for each  deal in response
  {
record_id = deal.get(“id”);
info “Found deal with id: ” + record_id;
is_record_found = True;
break;
  }
      if(is_record_found)
  {
break;
  }
}

if(is_record_found) {
  info “Updating module: ” + MODULE_TO_BE_UPDATED + ” record with id: ” + target_id;
  info “Updating lookup field: ” + LOOKUP_FIELD + ” with id: ” + record_id;
  params = Map();    params.put(LOOKUP_FIELD,record_id.toLong());
  response= zoho.crm.updateRecord(MODULE_TO_BE_UPDATED,target_id.toLong(),params);
      if(“Error”.equalsIgnoreCase(response.get(“status”)))
  {
info “Failed to update record: ” + response.get(“message”);
  }
  else
  {
  info “Hurray! record updated successfully.”;
  }
}

  • Click on Edit Arguments above the text area

  • Add the Function Arguments as seen in screenshot below -

  • Click on the Save button

  • Click on the Save button on the Function Editor

  1. Click on the Save button to save the Workflow. The Workflow will be active by default.

For the Outgoing and Incoming messages, from/to this custom module, the Lookup workflow will associate a relevant Module record to the SMS History record.

Notes:

  • Mobile number is SMS History record should exactly match with mobile field value in Custom Module (e.g., Deal).  

  • Although this code takes care of country code, yet Mobile numbers in custom modules should not be formatted.

Updated on Apr 10, 2024

ON THIS PAGE
No topics found!