The XML code does all the work for us once it is set up. Let's go through the structure. This provides the name of the case type that we will use:
We have a section called ActivityTypes
(note the plural!). It is a container for each activity type that is going to be associated with the Staff Record
case.
CiviCase always starts with <ActivityType>
named Open Case
.
<max_instances>
tells CiviCase how many instances of the activity to create. As a case is opened only once, there is only one instance.
The three activity types that we will use in our CiviCase are described next. You can see that the activity type named Annual appraisal
does not have a <max_instances>
tag. This is because annual appraisals take place each year and there is no defined maximum.
Now that we have set up what activities we will use for our case, we can schedule some of them on a timeline. For this, we create another section, called ActivitySets
, in the XML file.
Here we have the section called ActivitySets
. It is a container for one or more instances of ActivitySet
.
ActivitySet
is a set of scheduled activities that CiviCase will generate when our Staff Record
case is opened. When the case is first generated, CiviCase uses the <standard_timeline>
activity set to generate the initial set of activities. You can have additional ActivitySet
instances that use a different timeline. This is used to create activity branches within a case. In our example it could be the case that if an employee has a poor annual appraisal, we need to generate another set of activities to deal with the outcome. We can do this by having it configured in our XML file and applying it in the Add Timeline
section of the CiviCase screen.
Within each <ActivitySet>
instance, we have <ActivityType>
again, and we have some tags to schedule each type.
<reference_offset>
is the time in days that the activity will be scheduled. The offset is measured from whatever activity is entered in the <reference_activity>
tag.
If the referenced activity has multiple instances, such as a training course, then we use the <reference_select>
tag to pick the newest instance of the activity. If we do not want an activity schedule, we do not include it in <ActivitySet>
.
Finally, we have a <status>
tag that allows us to see the initial status of the activity when it is scheduled.
In our previous example, we have set the Contract acceptance
activity to be scheduled seven days after the Open Case
activity.
Finally, there is an XML section where we can create our relationships for each case. Each relationship we create becomes a role within the case.