You may want to send recurring newsletters to the customers. For example, greeting your customers on Birthdays or Anniversary Days or getting reminded of the next payment that you would receive from your customers.
The next birthday date or the next anniversary date or the next due by date can be automatically updated provided you edit and save the record once in between the two birthdays or two anniversary date, etc.
You can use this date to send the greetings or newsletters or alert the customers for payments.
Please follow these steps:
Deluge Script:
void workflowspace.AnniversaryDate(int potID,string Anniversary_Date)
{
resp = zoho.crm.getRecordById("Potentials",input.potID);
respStr=resp.toString();
respMap=respStr.toMap();
startDateStr=respMap.get("Closing Date");
closeDate=startDateStr.toDate();
modifiedTime=(respMap.get("Modified Time")).toDate();
createdTime=(respMap.get("Created Time")).toDate();
anniversaryDateStr=respMap.get("Anniversary Date");
if(anniversaryDateStr == null)
{
anniversaryDate=closeDate.addMonth(1);
}
else
{
anniversaryDate=anniversaryDateStr.toDate();
modifyMonth=(modifiedTime.getMonth()).toString();
anniversaryMonth=(anniversaryDate.getMonth()).toString();
if(anniversaryDate.getYear() < modifiedTime.getYear())
{
anniversaryDate=anniversaryDate.addMonth(1);
info "Year" + anniversaryDate;
}
else
{
if((anniversaryDate.getYear() <= modifiedTime.getYear()) && (anniversaryMonth.toDecimal() < modifyMonth.toDecimal()))
{
anniversaryDate=anniversaryDate.addMonth(1);
info "Month" + anniversaryDate;
}
else
{
if(((anniversaryDate.getYear() <= modifiedTime.getYear()) && (anniversaryMonth.toDecimal() <= modifyMonth.toDecimal())) && (anniversaryDate.getDay() < modifiedTime.getDay()))
{
anniversaryDate=anniversaryDate.addMonth(1);
}
}
}
}
crupt = zoho.crm.updateRecord("Potentials",input.potID.toString(),{input.Anniversary_Date:anniversaryDate});
}
Note: We have done this custom function for the anniversary date in the potentials module which will be calculated based on the Potential closed date. If you want this in a different module and for a different field, you need to change the module name and the field name in the custom function.
Please refer to the following link to know more about this feature:
https://www.zoho.com/crm/help/automation/custom-functions.html