Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //get deal details
- deal_details = zoho.crm.getRecordById("Deals",deal_id);
- deal_name = ifNull(deal_details.get("Deal_Address"),deal_details.get("Deal_Name"));
- info "deal name:" + deal_name;
- deal_owner_id = deal_details.getJSON("Owner").get("id");
- contact_name = deal_details.getJSON("Contact_Name").get("name");
- contact_id = deal_details.getJSON("Contact_Name").get("id");
- workdrive_folder_id = deal_details.get("Workdrive_Folder_ID");
- potential_team_folder_id = zoho.crm.getOrgVariable("workdrive_potential_folder");
- info potential_team_folder_id;
- //create workdrive folder under potential folder if the workdrive id is null
- if(workdrive_folder_id.isNull())
- {
- create_deal_folder = zoho.workdrive.createFolder(deal_name,potential_team_folder_id,"workdrive");
- info create_deal_folder;
- workdrive_folder_id = create_deal_folder.getJSON("data").get("id");
- update_deal = zoho.crm.updateRecord("Deals",deal_id,{"Workdrive_Folder_ID":workdrive_folder_id});
- }
- //get list of all upcoming tasks and delete the monthly tasks
- delete_list = list();
- related_tasks = zoho.crm.getRelatedRecords("Tasks","Deals",deal_id);
- for each task in related_tasks
- {
- task_type = task.get("Task_Type");
- if(task_type.containsIgnoreCase("nurture"))
- {
- task_id = task.get("id");
- delete_list.add(task_id);
- }
- }
- if(!delete_list.isEmpty())
- {
- response = invokeurl
- [
- url :"https://www.zohoapis.com/crm/v3/Tasks?ids=" + delete_list
- type :DELETE
- connection:"crm_all"
- ];
- info response;
- }
- //replace with weekly tasks
- //create cma and set listing appointment
- cma_price = deal_details.get("CMA_price");
- if(cma_price.isNull())
- {
- task_map = Map();
- task_map.put("Subject","Create CMA and set listing appointment");
- task_map.put("Owner",deal_owner_id);
- task_map.put("Task_Type","Seller Nurture");
- task_map.put("Sub_Type","Call");
- task_map.put("Due_Date",zoho.currentdate);
- task_map.put("Description","Create CMA, save comps, Cromford data, etc. Create listing packet");
- task_map.put("$se_module","Deals");
- task_map.put("What_Id",deal_id);
- task_map.put("Who_Id",{"id":contact_id});
- task_map.put("Priority","Normal");
- create_task = zoho.crm.createRecord("Tasks",task_map,{"trigger":{"workflow"}});
- }
- //create set listing appointment
- task_map.put("Subject","After CMA is completed, call the lead and set a listing appointment to give them the info");
- task_map.put("Description","Appointment should be as soon as possible. Bring listing agreement and get it signed if possible");
- create_task = zoho.crm.createRecord("Tasks",task_map,{"trigger":{"workflow"}});
- //find the day of the week and input recurring data in the correct format
- day_of_week = zoho.currentdate.getDayOfWeek().toString();
- info day_of_week;
- day_of_week = day_of_week.replaceAll("1","MO");
- day_of_week = day_of_week.replaceAll("2","TU");
- day_of_week = day_of_week.replaceAll("3","WE");
- day_of_week = day_of_week.replaceAll("4","TH");
- day_of_week = day_of_week.replaceAll("5","FR");
- day_of_week = day_of_week.replaceAll("6","MO");
- day_of_week = day_of_week.replaceAll("7","MO");
- //build task map and start following up weekly in 1 week future
- task_map = Map();
- task_map.put("Subject","Follow up with " + contact_name + " about their home at " + deal_name);
- task_map.put("Owner",deal_owner_id);
- task_map.put("Task_Type","Seller Nurture");
- task_map.put("Sub_Type","Call");
- startdate = zoho.currentdate.addDay(7);
- 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")});
- task_map.put("Due_Date",zoho.currentdate);
- task_map.put("Description","Check in with seller, update market, comps, and Cromford report Data");
- task_map.put("$se_module","Deals");
- task_map.put("What_Id",deal_id);
- task_map.put("Who_Id",{"id":contact_id});
- task_map.put("Priority","Normal");
- create_task = zoho.crm.createRecord("Tasks",task_map,{"trigger":{"workflow"}});
Advertisement
Add Comment
Please, Sign In to add comment