Skip to content

Instantly share code, notes, and snippets.

@jeznag
Created June 28, 2015 09:21
Show Gist options
  • Select an option

  • Save jeznag/9a717efa3fb72344e811 to your computer and use it in GitHub Desktop.

Select an option

Save jeznag/9a717efa3fb72344e811 to your computer and use it in GitHub Desktop.
Generate potentials for subscription revenue
void add_additional_potentials (int potential_ID )
potential_obj = zoho.crm.getRecordById("Potentials",input.potential_ID);
month_list={1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
for each month in month_list
{
new_closing_date=(potential_obj.get("Closing Date")).toDate().addMonth(month);
new_potential_name=(("Auto-generated follow up potential for " + potential_obj.get(("Account Name"))) + " closing on ") + new_closing_date;
//check if there's already an existing potential for this month
existing_potential = zoho.crm.searchRecords("Potentials","(Potential Name|=|" + new_potential_name + ")",1,1);
info "Existing results: " + (existing_potential.size());
if(existing_potential.size() == 0)
{
//duplicate the map so we're not touching the original
new_potential_map=(potential_obj.toString()).toMap();
closing_date_str=new_closing_date.toString("MM/dd/yyyy");
new_potential_map.put("Closing Date",closing_date_str);
new_potential_map.put("Stage","Renewal");
new_potential_map.put("Potential Name",new_potential_name);
potential_add_resp = zoho.crm.create("Potentials",new_potential_map,1);
}
else
{
info ("Potential already exists for ") + new_closing_date;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment