// customization block:
// replace your client id and api key here
// you can find the client id and api key in Ideolve console - Profile - Connect to other apps - Select Zoho CRM - choose tab : Configure ZohoCRM
connectorClientId = "replace your client id here"
apiKey = "replace your api key here"
aDate = zoho.currenttime.subHour(2);
timeZone = "+05:30";
dateTime_DATE = aDate.getPrefix(" ").toString("yyyy-MM-dd");
dateTime_TIME = aDate.getSuffix(" ");
dateTime_FORMATTED = (dateTime_DATE + "T" + dateTime_TIME + timeZone).remove(" ");
info dateTime_FORMATTED;
queryMap = Map();
queryMap.put("select_query","select id from Deals where Last_Activity_Time >='" + dateTime_FORMATTED + "'");
response = invokeurl
[
url :"https://www.zohoapis.in/crm/v3/coql"
type :POST
parameters:queryMap.toString()
connection:"authfordelugecoql"
];
info response;
if(response.length() > 0)
{
deals = response.getJSON("data");
info deals;
for each deal in deals
{
dealid = deal.getJSON("id");
// attachmentListObject = Map();
// attachmentListObject.put("accountId",accountid);
attachmentsList = {};
attachmentsString = "";
info "Account Iteration";
//info account.getJSON("Attachments");
attachments = zoho.crm.getRelatedRecords("Attachments","Deals",dealid);
// info attachments;
for each attachment in attachments
{
// info attachment;
attachmentid = attachment.getJSON("id");
// info attachmentid;
Modified_Time = attachment.getJSON("Modified_Time");
Modified_Time = Modified_Time.subString(0,10) + " " + Modified_Time.subString(11,19);
Modified_Date = toDateTime(Modified_Time);
//info Modified_Date;
Current_Date = zoho.currenttime.subHour(2);
//info Current_Date;
if(Modified_Date >= Current_Date)
{
// info "true";
attachmentsList.insert(attachment);
FileName = attachment.getJSON("File_Name");
CreatedBy = attachment.getJSON("Created_By").getJSON("name");
FileDetails = "File Name: " + FileName + " Created By: " + CreatedBy + " Date: " + Modified_Date + "
";
attachmentsString = attachmentsString.concat(FileDetails);
}
}
//info attachmentsList;
info attachmentsList;
info attachmentsString;
info attachmentsList.size();
if(attachmentsList.size() > 0)
{
header = {"event-origin":"ZohoCRM","event-type":"AddComment","connector-client-id":connectorClientId,"x-api-key":apiKey,"Content-Type":"application/json"};
bodyMp = {"notehtmltext":"Attachments Added:
" + attachmentsString,"attachments":attachmentsList,"leadNo":dealid,"module":"Deals","version":1};
response = invokeurl
[
url :"https://api.ideolve.com/v3/connector/event"
type :POST
parameters:bodyMp.toString()
headers:header
];
info response;
}
}
}