3

Please help me in how to create the custom function to search records from custom module in zoho crm.

I am new to zoho crm so I do not have any idea about how to code for this. The workflow triggers on Event create.

In custom module LEADID is inserted into Lead Id field and I want to search record by Lead Id fields value from custom module. In function I passed the lead id for search record. Below is sample code which I create but it does not work .

Lead_id=input.LeadID.toString();
Event_id=input.EventID.toString();
rec = zoho.crm.getRecordById("Events",input.EventID);
resp = zoho.crm.searchRecords("CustomModule1","Lead Id",input.LeadID);
for each ele in resp
{
mp=map();
mp.put("Event Created Time",rec.get("Created Time"));
contactId=ele.get("CUSTOMMODULE1_ID");
updateResp = zoho.crm.updateRecord("CustomModule1",contactId,mp);
}
ZohoCoder
  • 385
  • 5
  • 15
Ashish Patil
  • 313
  • 1
  • 6
  • 15

2 Answers2

0

Here is sample API method using PHP ,code for getting record from Lead module using Lead ID

$auth = "*************************";// Auth Keys
$id="****************";// Record Id

////////////get data by Id from Zoho Lead Module ///////////
$get_url = "https://crm.zoho.com/crm/private/json/Leads/getRecordById?";
$get_query = "authtoken=".$auth."&scope=crmapi&id=".$id."";

$get_curl = curl_init();
curl_setopt($get_curl, CURLOPT_URL, $get_url);
curl_setopt($get_curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($get_curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($get_curl, CURLOPT_TIMEOUT, 60);
curl_setopt($get_curl, CURLOPT_POST, 1);
curl_setopt($get_curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($get_curl, CURLOPT_POSTFIELDS, $get_query);
$get_response = curl_exec($get_curl);
$jfo = json_decode($get_response);
echo "<pre>";
curl_close($get_curl);
print_r($jfo);
cokeman19
  • 2,405
  • 1
  • 25
  • 40
0

Instead of

resp = zoho.crm.searchRecords("CustomModule1","Lead Id",input.LeadID);

use

resp = zoho.crm.searchRecords("MODULE","(FIELD:equals:" + LeadID + ")");

For "CustomModule1" and "Lead Id" check the API name section to confirm whatever they're actually called.