Placeholder

Customer Forum

Create Task Set for Cases

Jamie (Workbooks Online) Posted: 2020-09-29 10:44

Workbooks has the ability to create a set of Activity records against a Case record automatically after creation based on a set of templates. This is useful if there are several actions that must be completed by one, or multiple members of a team once the Case is raised. This type of automation is useful in many different scenarios. Consider the following examples:

  • Customers using the "Create Cases from Order Line Items" functionality (see here). The Case record is used to track fulfillment of an Order Line Item. There might be several tasks that need completing for the Product purchased
  • Support teams provisioning new client accounts where there are several steps to complete to ensure the account is setup correctly and steps are not missed
  • HR teams onboarding new staff. Use a Case to track the new starter, and automatically create Activities to enable a smooth enrolment process
  • ... and of course, many other scenarios!

The following article focuses on how to configure a follow on process for our "Create Cases From Order Line Items functionality.

Use Case

In Workbooks, we have created an Event record which has a Product related to it under the Products tab. When this Product is sold, a Customer Order is created with a Line Item that uses the Product. We've already setup the Create Cases from Order Line Items automation, so Case records are being created automatically for every Order Line Item.

NOTE: It's important to ensure that the Event & Product fields are added as field mappings to the Create Cases for Order Line Items script to ensure that these values are available on a Case record.

We now need to create a set of template Activities for the Product sold so that our team know which actions to complete. There are 5 Activities that need actioning every time this Product is sold. See Step 2 below which provides a set of templates that we'll use for this example - Templates cannot be created until you have configured the required custom fields specified in Step 1 below.

Step 1: Configuration

There are a number of custom fields that are required for the Process Automation to work correctly. These are as follows:

# Field Name Data Type Record Type Description*  Notes
1 Template Task Checkbox Tasks Used by the Create Activities for Cases process. Used to indicate an Task is actually a Template record. This field must be set to TRUE for the process to find records used as templates. See Step 2 for more information.
2 Base Date Modifier Picklist Tasks Used by the Create Activities for Cases process. Used to calculate a new Due Date on created Task . When creating the Picklist, use the values "Add" and "Subtract" only.
3 Base Date Field Name Text Tasks Used by the Create Activities for Cases process. Used to indicate which field to use when calculating a new Due Date on created Task. Set this to the Report Column's API Name when creating template Activities. See Step 2 for more information. If left blank today's date is used instead.
4 No of Days Integer Tasks Used by the Create Activities for Cases process. The value stored is either added or subtracted from the Base Date Field name. This is the number of days to add to the Base Date Field Name's value if specified, or today's date if no field name is specified. If blank, or 0, then Today's date is the resulting Due Date.
5 Event Dynamic Linked Item Tasks Used by the Create Activities for Cases process. Identifies a list of valid Events that a Template Task can be linked to. The report used to drive this field's picklist values should be a report of ALL relevant Event records in Workbooks. Consider your criteria carefully.
6 Product Dynamic Linked Item Tasks Used by the Create Activities for Cases process. Identifies a list of valid Products that a Template Task can be linked to. Constrained by Event. The report used to drive this field's picklist values should be a report of ALL relevant Product records in Workbooks. Consider your criteria carefully. When configuring the field, constrain it by the Event field to only select Products for a selected Event.
7 Tasks Created

Checkbox

Cases Used by the Create Activities for Cases process. Set to TRUE once a Case is processed and used as a criteria to exclude a record from the Report.  

The above example uses the Event/Product fields as part of the matching criteria to find the relevant templates to copy. This allows you to configure a different template Task set based on the Event and therefore Product sold. If you wish to configure this for a different scenario, you can use any fields available on the Case record for matching values on the Activity. For example, you could use the Case Type or Product Category instead - in this scenario, create fields for Case Type and/or Product Category on the Activity instead of Event/Product Fields (ensure that these custom fields use the same picklists as their Case record counterparts). 

*NOTE: Whilst the Description is not a required field for creating a Custom Field, we recommend populating it with a useful description of how the field is being used in your system. This helps system admins to avoid accidentally deleting configuration that is used in automation.

Step 2: Create Template Tasks

Now that we've configured the required Custom Fields in Workbooks, we need to create Template Tasks that are related to our Event & Products that we can sell.

Example Templates:

# Subject Due Date Type Priority No of Days Base Date Field Name Base Date Modifier Event Product Assigned To
1 Team Intros  N/A To-do High 1   Add Test Event Test Product Production
2 Follow up  N/A To-do High 2   Add Test Event Test Product Production
3 Request designs 01/10/2020 To-do High       Test Event Test Product Production
4 Review designs with client N/A To-do Medium 5 design_deadline Subtract Test Event Test Product Production
5 Project close down 14/11/2020 To-do Low       Test Event Test Product Production

If you know the date that a Task needs to take place, we can populate the Due Date field on our Templates. The value specified will be retained on the newly created Task. If you have not specified a Due Date, then this can be calculated by using the Base Date Field Name, No of Days & Base Date Modifier fields.

If the Base Date Field Name is blank, then today's date is used as the default. The Base Date field name can be populated with a DATE column that is available on your Report, however, the column must be stored on your Case record, and cannot be part of a breadcrumb drill through to another record type otherwise the script will not work correctly. Dates can be calculated by adding or subtracting days i.e. setting the Base Date Modifier field value to Add or Subtract.

Further information on the examples above...

  • For the "Team Intros" task, we want the Due Date to be 1 day after today. Therefore, we set the No of Days to 1. Leave the Base Date Field Name blank and set the Base Date Modifier to Add. Leaving the Base Date Field Name blank assumes TODAY as the Base Date to calculate the new date from.
  • For the "Request Designs" task, we know that our Event has a start date of 01/12/2020 (because we've created a record in Workbooks already to track the Event & it's Attendees/Speakers etc). We specify in our Terms & Conditions that we must receive designs 2 months before the start date of an event to allow the team plenty of time to complete the project. Therefore, we can hardcode a Due Date into our Template Activity.
  • For the "Review Designs with Client" task, we've set on our Event record that all designs must be reviewed with the client, at least 5 days before the Design Deadline to allow for final amendments - assume 02/11/2020 for this example. Design Deadline is tracked as a field on our Event, but as part of the Create Cases for Line Items script, we store this value on Case record so we can add it to our report in Step 3 below, then reference the API Column Name (under the Advanced Tab of the Report Column) in our template Activity. The resulting date will be Design Deadline minus 5 days in the resulting Activity i.e. 28/10/2020.

You could also populate the Description field with detailed notes about the Task that needs completing. These values will transfer to any new activities. Custom Fields can also be transferred from the Template Task to the new Task. More on that in Step 5 below.

Step 3: Build a Report

Using Workbooks Reports, we'll build a report which identifies Cases that have been created by the Create Cases from Order Line Items functionality. This can be tweaked according to the scenario in which this automation is being set up to suit your needs.

The automation requires that your report has the following columns by default:

  • Id: Set the name of the column to Record Id before saving
  • Lock Version: Set the name of the column to Record Lock Version before saving
  • Contact > Id: Set the name of the column to Primary Contact before saving
  • Event > Name (custom field): Set the name of the column to Event before saving
  • Product > Product Code (custom field): Set the name of the column to Product before saving
  • Design Deadline (custom field): Leave this as the default name.

It's important that any columns you wish to use as matching fields on your Task or as Base Date Field Names are also added as columns to your report. In this example, we add Event & Product but this might be Case Type/Product Category, or any other field you wish to use based on your scenario. We also use a column called Design Deadline.

Next, under the Criteria Tab, add any relevant criteria to limit the Cases that the automation can pick up. In our example, we'll identify any Cases created by the Create Cases for Line Items script, and where the record has not already been processed by this script.

  • Created Through starts with Action Create Cases from Order Lines
  • Tasks created is false

Remember that you can specify additional criteria on top of the above or use completely different criteria to this example. The key is that the Case only appears on the Report once, and so adding a flag that is set to TRUE by the process excludes a record once it is processed.

Once you are happy with the resulting data set, save the report with a suitable name. You will need this in Step 5 below. In our example, we'll save the Report with the name "API - Create Activities for Cases". We'll leave the name of the default view created as "Details".

Step 4: Setup Scheduled Process

A Scheduled Process is used to automatically process data on the Report created in Step 3 above. Create a new Scheduled Process from Configuration > Automation > Processes > Scheduled Processes. Set the following fields:

  • Name: Create Activities for Cases
  • Script: Set to Script Library, then select Create Activity Set for a Record
  • Schedule: Set this according to your business requirements. Careful consideration for the volume of Cases and Activities is needed here
  • Enabled: Set to TRUE

Once configured, click Save and a new Parameter Values tab will appear. Proceed to Step 5 below to continue the setup.

Step 5: Setup Scheduled Process Parameters

From here, using the Scheduled Process created in Step 4, we can set a parameter values to control the behaviour of the process such as the Report it uses to identify the data to process, plus matching criteria to identify our Template Tasks and so on. An example is provided in the screenshot below.

The above parameters need setting for this process to function correctly and should be configured as per your database configuration and scenario, work through the list and set the parameters, using the notes in the Parameter Value column below to guide you:

# Parameter Name Parameter Description Parameter Value
1 contact_override When the source record type is a Case, and this setting is enabled, override the Primary Contact set in a template with the Primary Contact from the source record.

Set this parameter to TRUE if you want the Activities created to set the Primary Contact on these records to that of the Case record. Leave blank if you want to default the new Activity to the same value as the Template.

NOTE: A case has the concept of one Primary Contact by default. You can also create Custom Fields to track further contacts. The script can be configured to use your custom fields instead of the standard field, by changing the Report column for Primary Contact created in Step 3. Ensure that you use the contact's Id, rather than name.  

2 data_view_name The report name & data view name of the report used to control which records are processed by this script. In the format REPORT_NAME:VIEW_NAME

Set this to the name of the Report and View created in Step 3. For our report, we need to set this parameter to "API - Create Activities for Cases:Details".

NOTE: By default, Workbooks creates a view within the report called "Details" for you, but you can rename this as required. 

3 processed_field The field name to update once a record has been processed by this script to exclude it from the report used by this script.

In our example, we're using a field called "Activities Created" as configured in Step 1. Set the field name, not field label of that field in this parameter. If you are using the example field, the value to set is "cf_case_tasks_created"

NOTE: You can get field names from the API Reference in your database, or alternatively opening the field configuration screen for your chosen field.

4 processing_batch_size The number of records to process on each run. Defaults to 5 if not set. Set how many cases will be processed on each run. Typically the recommended value is 1. This allows the script to finish as quickly as possible and minimises timeout issues. For high volumes of Cases, set the Schedule to run more frequently instead.
5 record_type The human friendly name for the record type this script will relate Activities to. Currently supports "Cases" only. The current version of the script available only supports the value "Cases" here. Any other value will cause the script to error and no records will be processed.
6 source_record_matching_field Specify multiple fields separated by a newline. Use the source report column name here. Each field's value will be used to query Activities to find matching Template Activities to create against any records identified in the report used by this script.

We'll set this parameter to use the report columns that reference the Event and Product fields from our Case record. These columns should have been added to your Report in Step 3.

Use the following value for the parameter:

event
product

NOTE: If you've used different fields/report columns, update appropriately.

7 task_custom_field Specify custom fields that must be transferred from the template Activity to new Activities created by this process. Must be specified with new lines to separate fields. By default on standard fields are transferred.

In this example, this parameter value remains blank.

By default, only the standard Workbooks fields are transferred across to new records created by this script. If you have any custom fields that you would like to transfer to the new activities, they can be specified here by new lines. Again, use the field name, not the field label here.

8 task_matching_field Specify multiple fields separated by a newline. Each field's value will be used to query Activities to find matching Template Activities to create against any records identified in the report used by this script.

We'll set this parameter to use Activity fields for the Event and Product. These fields should have been added to Workbooks in Step 1.

Use the following value for the parameter:

cf_task_event
cf_task_product

NOTE: If you've used different fields, update appropriately. The script expects these fields to be in the same order as the "source_record_matching_field" report columns, otherwise a match may not be found.

Step 6: Run Process & Create New Activities

The end result when the process runs is that our new Case will have 5 Activities available under the "Activities" tab of that record. The script will copy the template Activities that we set up in Step 2, setting the Due Date, Subject, and so on according to the template record & any parameters that we configured in Step 5. The script will also update the Activities Created field to TRUE so that it is not included in our Report data set.

Process Results:

# Subject Due Date Type Priority Status Assigned To
1 Team Intros 01/10/2020 To-do High New Production
2 Follow up 02/10/2020 To-do High New Production
3 Request designs 01/10/2020 To-do High New Production
4 Review designs with client 28/10/2020 To-do Medium New Production
5 Project close down 14/11/2020 To-do Low New Production

Notice that the Primary Contact has also been set to the Case Contact in the resulting Activities - this is because our Scheduled Process parameter "contact_override" was set to TRUE in Step 5. The newly created Activities do not set the Product, Event, No of Days, Base Date Field Name or Base Date Modifier on them and cannot be used as Templates going forwards for future sales of our example Product.