REQUEST A DEMO

Automatic Subcase Creation

While working with a customer this week, they asked about automatic subcase creation, similar to Clarify’s Task Manager module.

 

For example, if a new case of type “New Employee” is created, then I want to automatically create 3 subcases:

  • One subcase for setting up network accounts, dispatched to the network queue
  • One subcase for ordering office furniture, dispatched to the furniture queue
  • One subcase for ordering a new computer, dispatched to the hardware queue

 

This is easily accomplished with a business rule and a simple script.

The script

 

A simple PowerShell script (my favorite new scripting environment) which takes 1 input parameter (a case id number), and then calls the CreateSubcase API that is part of the Dovetail SDK to create subcases and dispatch them to the appropriate queue.

 

$connectionString = “Data Source=moorea;Initial Catalog=dovetail;uid=gary;pwd=not4youris”;
$databaseType = “MSSQL”;

[system.reflection.assembly]::LoadWithPartialName(“fcsdk”) > $null
[system.reflection.assembly]::LoadWithPartialName(“FChoice.Toolkits.Clarify”) > $null

$config = new-object -typename System.Collections.Specialized.NameValueCollection
$config.Add(“fchoice.connectionstring”,$connectionString);
$config.Add(“fchoice.dbtype”,$databaseType);
$config.Add(“fchoice.disableloginfromfcapp”, “false”);

$ClarifyApplication = [Fchoice.Foundation.Clarify.ClarifyApplication]

if ($ClarifyApplication::IsInitialized -eq $false ){
$ClarifyApplication::initialize($config) > $null;
}

$ClarifySession = $ClarifyApplication::Instance.CreateSession()
$supportToolkit=new-object FChoice.Toolkits.Clarify.Support.SupportToolkit($ClarifySession)  

$CaseId = [string] $args[0]

$subcaseSetup = new-object FChoice.Toolkits.Clarify.Support.CreateSubcaseSetup($CaseId);
$subcaseSetup.DueDate = 
(get-date).AddDays(7);

$subcaseSetup.Title = “Create Network accounts for new employee”;
$subcaseSetup.Queue = “IS HelpDesk”;
$subcaseResult = $supportToolkit.CreateSubcase($subcaseSetup);

$subcaseSetup.Title = “Need Furniture for new employee”;
$subcaseSetup.Queue = “Furniture Requests”;
$subcaseResult = $supportToolkit.CreateSubcase($subcaseSetup);

$subcaseSetup.Title = “Need Computer for new employee”;
$subcaseSetup.Queue = “Hardware Requests”;
$subcaseResult = $supportToolkit.CreateSubcase($subcaseSetup);

The business rule

 

Object Type: Case
Rule Name/Description: New Employee Request
Start Event: Dispatch
Cancel Events: None
Conditions: Case Type = New Employee
Action Title: Create Subcases
Message Type: Command Line
Start Action: 0 minutes
From: Event Creation
Using: Elapsed Time
Message: C:\WINDOWS\system32\WINDOW~1\v1.0\powershell.exe C:\work\PowerShell\CreateNewEmployeeSubCases.ps1 “[Object ID]”

Try it out

 

Start the Rulemanager service. Create a new case with a case type of “New Employee”. Dispatch it to a queue. RuleManager will then fire the business rule, which will create the 3 subcases.

 

Looking at the activity log for the case, we can see the rule fired and that the 3 subcases were created:

 

activity_log

 

What I like about this approach is that you can easily modify the script to do exactly what you want, and not be bound by the constraints of a GUI such as in Task Mangler that tries to anticipate whatever complex business requirements you may have.

 

Rock on.