patrickjust3k

seller short nurture

May 17th, 2023
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.93 KB | None | 0 0
  1. //get deal details
  2. deal_details = zoho.crm.getRecordById("Deals",deal_id);
  3. deal_name = ifNull(deal_details.get("Deal_Address"),deal_details.get("Deal_Name"));
  4. info "deal name:" + deal_name;
  5. deal_owner_id = deal_details.getJSON("Owner").get("id");
  6. contact_name = deal_details.getJSON("Contact_Name").get("name");
  7. contact_id = deal_details.getJSON("Contact_Name").get("id");
  8. workdrive_folder_id = deal_details.get("Workdrive_Folder_ID");
  9. potential_team_folder_id = zoho.crm.getOrgVariable("workdrive_potential_folder");
  10. info potential_team_folder_id;
  11. //create workdrive folder under potential folder if the workdrive id is null
  12. if(workdrive_folder_id.isNull())
  13. {
  14. create_deal_folder = zoho.workdrive.createFolder(deal_name,potential_team_folder_id,"workdrive");
  15. info create_deal_folder;
  16. workdrive_folder_id = create_deal_folder.getJSON("data").get("id");
  17. update_deal = zoho.crm.updateRecord("Deals",deal_id,{"Workdrive_Folder_ID":workdrive_folder_id});
  18. }
  19. //get list of all upcoming tasks and delete the monthly tasks
  20. delete_list = list();
  21. related_tasks = zoho.crm.getRelatedRecords("Tasks","Deals",deal_id);
  22. for each task in related_tasks
  23. {
  24. task_type = task.get("Task_Type");
  25. if(task_type.containsIgnoreCase("nurture"))
  26. {
  27. task_id = task.get("id");
  28. delete_list.add(task_id);
  29. }
  30. }
  31. if(!delete_list.isEmpty())
  32. {
  33. response = invokeurl
  34. [
  35. url :"https://www.zohoapis.com/crm/v3/Tasks?ids=" + delete_list
  36. type :DELETE
  37. connection:"crm_all"
  38. ];
  39. info response;
  40. }
  41. //replace with weekly tasks
  42. //create cma and set listing appointment
  43. cma_price = deal_details.get("CMA_price");
  44. if(cma_price.isNull())
  45. {
  46. task_map = Map();
  47. task_map.put("Subject","Create CMA and set listing appointment");
  48. task_map.put("Owner",deal_owner_id);
  49. task_map.put("Task_Type","Seller Nurture");
  50. task_map.put("Sub_Type","Call");
  51. task_map.put("Due_Date",zoho.currentdate);
  52. task_map.put("Description","Create CMA, save comps, Cromford data, etc. Create listing packet");
  53. task_map.put("$se_module","Deals");
  54. task_map.put("What_Id",deal_id);
  55. task_map.put("Who_Id",{"id":contact_id});
  56. task_map.put("Priority","Normal");
  57. create_task = zoho.crm.createRecord("Tasks",task_map,{"trigger":{"workflow"}});
  58. }
  59. //create set listing appointment
  60. task_map.put("Subject","After CMA is completed, call the lead and set a listing appointment to give them the info");
  61. task_map.put("Description","Appointment should be as soon as possible. Bring listing agreement and get it signed if possible");
  62. create_task = zoho.crm.createRecord("Tasks",task_map,{"trigger":{"workflow"}});
  63. //find the day of the week and input recurring data in the correct format
  64. day_of_week = zoho.currentdate.getDayOfWeek().toString();
  65. info day_of_week;
  66. day_of_week = day_of_week.replaceAll("1","MO");
  67. day_of_week = day_of_week.replaceAll("2","TU");
  68. day_of_week = day_of_week.replaceAll("3","WE");
  69. day_of_week = day_of_week.replaceAll("4","TH");
  70. day_of_week = day_of_week.replaceAll("5","FR");
  71. day_of_week = day_of_week.replaceAll("6","MO");
  72. day_of_week = day_of_week.replaceAll("7","MO");
  73. //build task map and start following up weekly in 1 week future
  74. task_map = Map();
  75. task_map.put("Subject","Follow up with " + contact_name + " about their home at " + deal_name);
  76. task_map.put("Owner",deal_owner_id);
  77. task_map.put("Task_Type","Seller Nurture");
  78. task_map.put("Sub_Type","Call");
  79. startdate = zoho.currentdate.addDay(7);
  80. task_map.put("Recurring_Activity",{"RRULE":"FREQ=WEEKLY;INTERVAL=1;BYDAY=" + day_of_week + ";DTSTART=" + startdate.toString("yyyy-MM-dd") + ";UNTIL=" + startdate.toDate().addMonth(6).toString("yyyy-MM-dd")});
  81. task_map.put("Due_Date",zoho.currentdate);
  82. task_map.put("Description","Check in with seller, update market, comps, and Cromford report Data");
  83. task_map.put("$se_module","Deals");
  84. task_map.put("What_Id",deal_id);
  85. task_map.put("Who_Id",{"id":contact_id});
  86. task_map.put("Priority","Normal");
  87. create_task = zoho.crm.createRecord("Tasks",task_map,{"trigger":{"workflow"}});
Advertisement
Add Comment
Please, Sign In to add comment