Article published on the 7th of June, 2022.
1. Case description
Using templates for entities can help speed up the process of creating new projects, cases, clients, or other types of entities where a lot of meta needs to be provided.
We can divide the case into the following bullet points:
As a Case Manager, I would like to be able to:
- Exclusively be able to open an existing case and mark it as a template from a button in the My Tools panel.
- Select which field values from the original entity should be copied over when creating a new case from the template (e.g. Case Responsible or Priority).
- Open a wizard in which I can select a template case and create a new case from it.
- Provide additional meta data to what is automatically provided by the template.
- Select whether to add the new entity to my favorites.
We can split the requirements for this case up into two processes in WorkPoint Business Automation:
- Mark case as template
- Create case from template
We are also going to make use of two fields apart from all your standard case-related fields on the business module:
|Field name||Field type||Field description|
|IsTemplate||Boolean||Used to keep track of which cases are marked as templates.|
|TemplateFieldOptions||Multiple lines of text||Used to store a string representation of which field values will be copied from the template case onto the new case, e.g. Title, Priority, or Case Responsible.|
2.1. Mark case as template
The "Mark case as template" process would be a user process, run from a My Tools button.
It would include a Custom Form step, which would contain boolean fields for each of the fields which should be copied to new cases created from the template,as shown in the following example:
Following from that, an Update Entity would update tho fields for the entity in the business module list: A boolean field, signaling that the case is a template, and a multi-line text field storing the settings from the Custom Form.
The Update Entity step would use the following adaptive expression for the value of the "TemplateFieldOptions" field:
"FieldChoices" is the name of the Custom Form step.
In this way, we can store information about which fields should be copied from the case template to the new case. We can then use this information in the "Create case from template" process, which we are going to cover next.
2.2. Create case from template
The "Create case from template" process would be a bit more complicated than the Mark case as template process.
We begin by using a Search Entities step, in order to select the template case we want to create a new case from. In our implementation, we have created a view which uses a filter to only show cases for which the "IsTemplate" field is set to "Yes".
Once a template case is selected, we continue to an Entity Form step. This step allows the user to provide meta data for the new case we are going to create, but crucially, we can also use the settings stored in the "TemplateFieldOptions" to automatically fill some fields with values from the template.
In this implementation, we do this by checking the boolean values in the "TemplateFieldOptions" field of the template we selected to see if they are set to "true". If they are, we fill the corresponding field in the Entity Form with the value from the template. If it is not, we pass an empty string into the field in the Entity Form.
We use the following adaptive expression for this purpose:
if(json(SelectTemplateForm.TemplateFieldOptions).IncludeTitle, SelectTemplateForm.Title, "")
In this instance, "IncludeTitle" is the name of the boolean field which was set when the case was marked as template. SelectTemplateForm is the name of the search form from the "Create case from template" process in which users select which template to use.
To help indicate which meta data is pulled from the template, we can set those fields as read-only.
In this way, users would only need to fill in the meta data which is not automatically added from the template.
We can then use a Copy Entity Form step to choose which list contents we would like to copy over from the template case site, and finally a Copy Entity step to actually make a new case with all our meta data and list contents. If we want to, we can add the following two steps; A Custom Form with a boolean to select if the users wants the new case to be added to their favorites, and a step in the end of the process which sets the case as favorite accordingly.
From this description, the process could look something like the following:
In this section, we will describe the usage of the previously mentioned Mark case as template- and Create case from template processes.
3.1. Executing the Mark case as template process
As previously mentioned, we can use a My Tools button to execute the Mark case as template process:
In the process, we can select which field values should be copied over when creating a new case based on the template we are creating:
Once completed, the IsTemplate field is set to "Yes" for the entity, and the field choices are stored as text in the "TemplateFieldOptions" field on the case:
3.2. Executing the Create case from template process
The Create case from template process is also started from a My Tools button:
In the first step of the process, we select from which case template we want to create a new case:
In the next step, we can input meta data for the new case. We can also see that the Title- and the Priority fields are automatically filled with data from the template case:
Next, we get a chance to select from which lists on the template we want to copy content over to the new case:
In this implementation, we have added a Custom Form where users can select whether the new case should be added to the user's favorites:
Next, the process creates a new case based on the information coming from the template, as well as the meta data input manually in the Entity Form:
Once completed, we have a new case in our Cases business module:
The following video describes the Cases from templates case as well as the execution.