Saturday, January 24, 2015

Auto populating custom field in Zoho CRM using criteria


I saw this question in the Zoho forums and thought I'd respond:
Is there way to auto-populate a field given a set of criteria?

For example, I'd like all Potentials that close between a set of dates (i.e. between 1/1/2015 and 5/1/2015) to automatically populate the same text in a custom field I've called "Group."

My Answer

  1. void   modify_group_for_jim_based_on_closing_date  ( int potential_id   )
  2. potential = zoho.crm.getRecordById("Potentials",input.potential_id);
  3. the_closing_date=(potential.get("Closing Date")).toDate();
  4. date_window_1=("1/1/2015").toDate();
  5. date_window_2=("1/5/2015").toDate();
  6. date_window_3=("1/6/2015").toDate();
  7. date_window_4=("1/11/2015").toDate();
  8. potential_map=map();
  9. if((the_closing_date  >=  date_window_1)  &&  (the_closing_date  <=  date_window_2))
  10. {
  11. potential_map.put("Group","Group 1");
  12. }
  13. else if((the_closing_date  >=  date_window_3)  &&  (the_closing_date  <=  date_window_4))
  14. {
  15. potential_map.put("Group","Group 2");
  16. }
  17. else
  18. {
  19. potential_map.put("Group","Unknown Group");
  20. }
  21. potential_id_str=input.potential_id.toString();
  22. updatedPotential = zoho.crm.updateRecord("Potentials",potential_id_str,potential_map);
  23. info "Response: " + updatedPotential;

No comments:

Post a Comment