Functions Integration Tasks - Migration from v1 to v2

Integration tasks are a set of pre-defined functions that allow you to create, update, and fetch records from Zoho CRM through functions.

You can simply use these method names in your Deluge script along with the required data to make API calls.

This guide will help you migrate from using Integration tasks in v1 to v2.

What is different in v2 Integration tasks?

Differencesv1v2
Integration Tasks
  1. The syntax for v1 Integration tasks contains "v1" after the service name.
    Example: response = zoho.crm.v1.getRecords("Leads",1,100);

  2. It uses field labels in the request.

  1. The syntax for v2 Integration tasks does not have the version number in its syntax.
    Example: response = zoho.crm.getRecords("Leads",1,200);

  2. It uses field API names in the request.

Time Formatv1 uses the "yyyy-mm-dd hh:mm:ss" time and date format.v2 uses the ISO date time format (yyyy-MM-dd'T'HH:mm:ssXXX). You can also change the time format from ISO to "yyyy-mm-dd hh:mm:ss" format, or set the time zone to yours.
AutomationYou can only trigger workflow rules via integration tasks.You can trigger workflow, blueprint, and approval via integration tasks.
Multi-select lookup fieldPass the values of the multi-select lookup field to be updated as comma-separated values in a string.Pass the values of the multi-select lookup field to be updated as a list.
Invoke URLThe v1 invoke URL uses "https://crm.zoho.com/crm/private/xml"In v2, the invoke URL is domain-specific. Example, "https://www.zohoapis.com/crm/v2/", "https://www.zohoapis.com.cn/crm/v2/" etc.

Create Record API Syntax

  • v1
  • v2
 

v1

<variable>=zoho.crm.v1.create(<module_name>,{<data_map>});

v2

<variable>=zoho.crm.createRecord(<module_name>,{<data_map>},{<optional_data_map>});

Create Record API Example

  • v1
  • v2
 

v1

leadInfo = map();
leadInfo.put("Company", input.Company_Name);
leadInfo.put("Last Name", input.Last_Name);
leadInfo.put("Phone", input.Phone);
leadInfo.put("Email", input.Email_Address);
leadInfo.put("Secondary Email", input.Secondary_Email);
leadInfo.put("Country", input.Country);
response = zoho.crm.v1.create("Leads",leadInfo);

v2

leadInfo = map();
leadInfo.put("Company", input.Company_Name);
leadInfo.put("Last_Name", input.Last_Name);
leadInfo.put("Phone", input.Phone);
leadInfo.put("Email", input.Email_Address);
leadInfo.put("PO_Box", input.PO_Box);
leadInfo.put("Country", input.Country);
response = zoho.crm.createRecord("Leads",leadinfo); 

Get Records API Syntax

  • v1
  • v2
 

v1

<variable>=zoho.crm.v1.getRecords(<module_name>,[<page>],[<per_page>], {<optional_data_map>}); 

v2

<variable>=zoho.crm.getRecords(<module_name>,[<page>],[<per_page>], {<optional_data_map>}); 

Get Records API Example

  • v1
  • v2
 

v1

response = zoho.crm.v1.getRecords("Leads",1,100); 

v2

response = zoho.crm.getRecords("Leads",1,200); 

Get Record by ID API Syntax

  • v1
  • v2
 

v1

<variable>=zoho.crm.v1.getRecordById(<module_name>,id); 

v2

<variable>=zoho.crm.getRecordById(<module_name>,id); 

Get Record by ID API Example

  • v1
  • v2
 

v1

response = zoho.crm.v1.getRecordById("Leads",1234567890); 

v2

response = zoho.crm.getRecordById("Leads",1234567890); 

Update Record API Syntax

  • v1
  • v2
 

v1

<variable>=zoho.crm.v1.updateRecord(<module_name>,id,{<data_map>}); 

v2

<variable>=zoho.crm.updateRecord(<module_name>,id,{<data_map>},{<optional_data_map>}); 

Update Record API Example

  • v1
  • v2
 

v1

leadInfo = map();
leadInfo.put("Company", input.Company_Name);
leadInfo.put("Last Name", input.Last_Name);
response = zoho.crm.v1.updateRecord("Leads","1234567890",leadInfo); 

v2

leadInfo = map();
leadInfo.put("Last_Name", input.Last_Name);
leadInfo.put("Phone", input.Phone);
response = zoho.crm.updateRecord("Leads",123456789,leadinfo); 

Time Manipulation

  • v1
  • v2
 

v1

recordInfo = zoho.crm.v1.getRecordById("Leads",1757572000004432004);
lastActivityTime = recordInfo.get("Modified Time");// To get the last activity time of the lead record
Result: 2019-05-22 17:08:03 

v1 integration tasks return time only in the format "yyyy-mm-dd hh:mm:ss".

v2

recordInfo = zoho.crm.getRecordById("Leads",1757572000004432004);
lastActivityTime = recordInfo.get("Last_Activity_Time");// To get the last activity time of the lead record
Result: 2019-06-30'T'13:20:34IST 

v2 Integration tasks accept and return the ISO format "(yyyy-MM-dd'T'HH:mm:ssXXX)".

The Deluge script also has the in-built function toTime to convert the ISO time format into the normal format (yyyy-mm-dd hh:mm:ss).

normalActivityTime = lastActivityTime.toTime("yyyy-MM-dd'T'HH:mm:ssXXX");
Result: 2019-06-30 13:20:34 

The following script lets you set the last activity time of the record to the time zone of your choice. Here, "your_time_zone" should contain your time zone such as IST, PST, PDT, etc,.

timeZoneValue = lastActivityTime.toTime("yyyy-MM-dd'T'HH:mm:ssXXX").toString("yyyy-MM-dd HH:mm","your_time_zone");

Automation

  • v1
  • v2
 

v1

recordInfo = zoho.crm.v1.getRecordById("Leads",1757572000004432004);
lastActivityTime = recordInfo.get("Modified Time");// To get the last activity time of the lead record
Result: 2019-05-22 17:08:03

v1 Integration tasks support triggering only the workflows while creating or updating a record.

Here,
Leads is the module name
Data_Map is the list of fields you want to update
0 represents whether or not you want to use duplicate checks while inserting
false/true is the value of wfTrigger param. True represents that workflow is triggered, false represents workflow is not triggered.

v2

triggers = list();
triggers.add("workflow");
triggers.add("approval");
triggers.add("blueprint");

zoho.crm.createRecord("Leads", dataMap,{"trigger":triggers});

In v2, you can trigger workflows, blueprints, as well as approvals via Integration tasks. To trigger all automation rules use the above code.

Blueprint and Approvals get triggered by default, even if you do not specify them in the optional datamap.

zoho.crm.createRecord("Leads", dataMap);

If you do not want to trigger any of the automation rules, send an empty list in the request as given below.

zoho.crm.createRecord("Leads", dataMap,{"triggers":[]});

Multi-select Lookup Field

  • v1
  • v2
 

v1

newlist = "value1,value2,value3";
mp = Map();
mp.put("Active Products",newlist);
update = zoho.crm.v1.updateRecord("Accounts",acctId.toString(),mp);
info mp;
info update;

In v1 integration task, to update a multi-select lookup field, pass the values of that field as comma separated values in a string as shown above.

v2

newlist = {"value1","value2","value3"};
mp = Map();
mp.put("Active_Products",newlist);
update = zoho.crm.updateRecord("Accounts",acctId.toLong(),mp);
info mp;
info update;

In v2 integration task, to update a multi-select lookup field, pass the values of that field in a list as shown above.

Invoke URL

Get Records

  • v1
  • v2
 

v1

response = invokeurl
[
	url :"https://crm.zoho.com/crm/private/xml/Leads/getRecords"
	type :GET
	connection:"crmv1"
];

v2

RecordInfo = Map();
RecordInfo.put("Company","Zylker");
RecordInfo.put("Last_Name","Downey");
RecordInfoarray = List();
RecordInfoarray.add(RecordInfo);
Param=Map();
Param.put("data", RecordInfoarray);
triggerList = List();
triggerList.add("workflow");
Param.put("trigger",triggerList);
response = invokeUrl [
    url : "https://www.zohoapis.com/crm/v2/Leads/3992156000000858001"
    type : PUT
    parameters : Param.toString()
    connection : v2api
];
return response;

Insert Records

  • v1
  • v2
 

v1

param = Map();
param.put("xmlData","<Leads><row no=\"1\"><FL val=\"Last Name\">Robert</FL></row></Leads>");
response = invokeurl
[
	url :"https://crm.zoho.com/crm/private/xml/Leads/insertRecords"
	type :POST
	parameters:param
	connection:"crmv11"
];

v2

RecordInfo = Map();
RecordInfo.put("Company","Zylker");
RecordInfo.put("Last_Name","Robert");
RecordInfoarray = List();
RecordInfoarray.add(RecordInfo);
Param=Map();
Param.put("data", RecordInfoarray);
triggerList = List();
triggerList.add("workflow");
Param.put("trigger",work);
response = invokeUrl [
    url : "https://www.zohoapis.com/crm/v2/Leads"
    type : POST
    parameters : Param.toString()
    connection : v2api
];
return response;

Update Records

  • v1
  • v2
 

v1

param = Map();
param.put("xmlData","<Leads><row no=\"0\"><FL val=\"Last Name\">Boyle_1</FL><FL val=\"Start DateTime\">2009-08-04 01:00:00</FL><FL val=\"End DateTime\">2009-08-05 01:00:00</FL></row></Leads>");
param.put("newFormat","1");
param.put("id","3992156000000858001");
response = invokeurl
[
	url :"https://crm.zoho.com/crm/private/xml/Leads/updateRecords"
	type :POST
	parameters:param
	connection:"crmv11"
];

v2

RecordInfo = Map();
RecordInfo.put("Company","Zylker");
RecordInfo.put("Last_Name","Downey");
RecordInfoarray = List();
RecordInfoarray.add(RecordInfo);
Param=Map();
Param.put("data", RecordInfoarray);
triggerList = List();
triggerList.add("workflow");
Param.put("trigger",triggerList);
response = invokeUrl [
    url : "https://www.zohoapis.com/crm/v2/Leads/3992156000000858001"
    type : PUT
    parameters : Param.toString()
    connection : v2api
];
return response;

Search Records

  • v1
  • v2
 

For more details, refer to the REST API Guide.