User Tips: Adding a Review Task to a Record

User Tips: Adding a Review Task to a Record

We use tasks to manage stuff that needs to be done but people then need to create a task add subject set due date, etc, etc....

To simplify things... I added a custom date field that whenever set, creates the task and sets the due date for the user who just set the field. 

Scenario:
A sales rep wants to create a task to review a quote. In this case the rep just sets the "Review On" date field which triggers a function that
- Creates and Names the Task
- Sets the task owner as the user who just triggered the action
- Sets the review task due date
- Then resets the "Review On" field to blank (so anyone else can use it to trigger their own tasks)

The Sales Rep then each day checks his "My Today & Overdue Tasks" to see what's on his agenda for the day.

Summary Steps to implement this
- Add a custom Date field to the relevant module
- Create a Custom Function (code below)
- Create a Workflow that triggers whenever the date field is edited (runs on every edit)


Custom Function Code
  1. //Grab Record Details using quoteId which is passed in (you can pass in each field via arguments instead of doing this step)
  2. quoteDetails = zoho.crm.getRecordById("Quotes",quoteId);

  3. //Get the current logged in user email and use that to get full user details
  4. userEmail = zoho.loginuserid;
  5. CRMmap = Map();
  6. CRMusers = zoho.crm.invokeConnector("crm.getusers",CRMmap);
  7. CRMuserlist = CRMusers.getJSON("response").getJSON("users").toJSONList();

  8. //Loop through our user list and look for a match to pull out additional info
  9. for each  user in CRMuserlist
  10. {
  11. if(user.getJSON("email") == userEmail)
  12. {
  13. CRMid = user.getJSON("id");
  14. firstName = user.getJSON("first_name");
  15. lastName = user.getJSON("last_name");
  16. taskOwnerName = firstName + " " + lastName;
  17. taskOwner = {"name":firstName + " " + lastName,"id":CRMid};
  18. }
  19. }

  20. //Setting our Task Fields
  21. quoteSubj = quoteDetails.get("Subject");
  22. quoteNum = quoteDetails.get("Quote_Num");
  23. quoteReviewOn = quoteDetails.get("Review_On");
  24. taskText = "Review ";

  25. //Set the subject for the task
  26. taskSubject = taskText + " Quote #" + quoteNum + " - " + quoteSubj + "";

  27. //Create Task Map
  28. tMap = Map();
  29. tMap.put("$se_module","Quotes");
  30. tMap.put("What_Id",quoteId);
  31. tMap.put("Subject",taskSubject);
  32. tMap.put("Owner",taskOwner);
  33. tMap.put("Due_Date", quoteReviewOn);
  34. tMap.put("Priority","3. Normal - Do Later");
  35. tMap.put("Status","Not Started");

  36. //Create the task
  37. createResp = zoho.crm.createRecord("Tasks",tMap);

  38. //Reset the "Review_On" date field for the next person to use.
  39. quoteMap = Map();
  40. quoteMap("Review_On","");
  41. resp = zoho.crm.updateRecord("Quotes",quoteId,quoteMap);
      

We use the same concept across multiple modules and it helps users manage and stay on top of their "To Do" list my making it easy for them to create tasks. Depending on the module the Task subject line is changed. The code can be edited to set the reminder date and other fields also. 

Hopefully helps!