Automatically create tasks via custom Triggers or Process Builder.


Create a new Process in Process Builder

  • Add Object
    - select any criteria suitable for the situation, e.g. when a record is created
  • Add Criteria
    - enter conditions or formula - or just execute
  • Add Immediate (or scheduled) Action
    - Action Type: Apex
    - Apex Class: Add Checklist Tasks (first) -- or Add Checklist Tasks (all)
    - Set Apex Variables
    -- Field: ids
    -- Type: Field Reference
    -- Value: The Id of the record


Process Builder Add Action

Then, activate the Process.


Apex Details

We provide the following APEX classes/methods which you can invoke via Process Builder or call from a custom class or trigger.  The general steps are:

  • Find the checklists for the object type of the record (e.g. Account)
    • ensure that the checklist matches the Only for Object (if defined) and the Only if valid conditions (if defined)
    • the sequence is based on the checklist Code
  • Create Tasks from the Checklist Items
    • Assign to the Owner of the Task to the owner of the record
      -- or if defined in the Checklist Item, the Assigned User -- or the Dynamically Assigned User
    • Set the Due Date of the Task based on today's date and the Date Offset Days (and Use Workdays) for tasks without prerequisites
    • Set the Status of the Task to Not Started or Waiting on someone else (for tasks with prerequisites)


Create Tasks only for the first matching checklist:

global class acheck.CheckListCreate {
  /**
   * Process Builder Interface
   * @param ids list of record ids - select Type: Field Reference and the Value: id 
   */
  @InvocableMethod(
    label='Add Checklist Tasks (first)' 
    description='Creates Tasks from the Items of the highest priority matching CheckList')
  global static void create(List<String> ids) {}

  /**
   * Add CheckList Tasks of first matching Checklist for record with Id
   * @param whatId the id of the target record
   * @return list of the saved tasks or null if no checklist found
   */
  global static List<Task> forId(Id whatId) {}
}


Create Tasks only for all matching checklists:

global class acheck.CheckListCreateAll {
  /**
   * Process Builder Interface
   * @param ids list of record ids - select Type: Field Reference and the Value: id 
   */
  @InvocableMethod(
    label='Add Checklist Tasks (all)' 
    description='Creates Tasks from the Items of all matching CheckLists')
  global static void createAll(List<String> ids) {}

  /**
   * Add all CheckList Tasks for record with Id
   * @param whatId the id of the target record
   * @return list of the saved tasks or null if no checklist found
   */
  global static List<Task> forIdAll(Id whatId) {}
}