//Deluge has predefined integrations with zoho services. Zoho Sheet is also supported
//sheet's getRecords API can be used to fetch all records in a sheet or specific records based on a criteria
//Required parameters
//1. Resource ID - can be picked from sheet url
//2. Sheet Name - Name of the sheet at the bottom
//4. connection link name
queryMap = Map();
//criteria format: "column name"="column value"
//example: "Client ID"="1001"
queryMap.put("criteria","\"Client ID\"=" + client_id);
data = zoho.sheet.getRecords("krz56389e2107d77a434ab731d3271a00c77d","Sheet1",queryMap,"zoho_sheet");
//this will fetch the records matching the criteria above
records = data.getJson("records");
//In our case, only record will be returned as client id is unique. So we are fetching the record at index 0
record = records.get(0);
//fetching each value by its column name
name = record.get("Client Name");
contact = record.get("Contact").toString();
location = record.get("Location");
info name;
//debugger print name
paramMap = Map();
//constructing the values in params for updating in card
//mapping with associated field name in qntrl
paramMap.put("customfield_shorttext18",name);
paramMap.put("customfield_shorttext16",contact);
paramMap.put("customfield_shorttext11",location);
job = invokeurl
[
type :POST
parameters:paramMap
connection:"zoho_qntrl"
];
info job;
//debugger to print update job response
//we are using the same criteria that was used to fetch the record
newValues = Map();
newValues.put("Status","Updated");
optMap = Map();
updateResp = zoho.sheet.updateRecords("krz56389e2107d77a434ab731d3271a00c77d","Sheet1","\"Client ID\"=" + client_id,newValues,optMap,"zoho_sheet");
info updateResp;