// 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; payload = {"select_query":"select * from Accounts where Last_Activity_Time >='" + aDate + "'"}; queryMap = Map(); queryMap.put("select_query","select id from Accounts 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) { accounts = response.getJSON("data"); info accounts; for each account in accounts { accountid = account.getJSON("id"); attachmentsList = {}; attachmentsString = ""; info "Account Iteration"; attachments = zoho.crm.getRelatedRecords("Attachments","Accounts",accountid); for each attachment in attachments { info attachment; attachmentid = attachment.getJSON("id"); Modified_Time = attachment.getJSON("Modified_Time"); Modified_Time = Modified_Time.subString(0,10) + " " + Modified_Time.subString(11,19); Modified_Date = toDateTime(Modified_Time); Current_Date = zoho.currenttime.subHour(2); if(Modified_Date >= Current_Date) { 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 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":accountid,"module":"Accounts","version":1}; response = invokeurl [ url :"https://api.ideolve.com/v3/connector/event" type :POST parameters:bodyMp.toString() headers:header ]; info response; } } }