REQUEST A DEMO

cctvtmmain : a useful, but broken, and poorly named, utility for closing child cases

We recently received an inquiry from a customer asking about Clarify’s cctvtmmain utility. Specifically, it was throwing a useless error message, and they wanted our help. Our first response was WTF is cctvtmmain?

A little research, and we discovered that its a utility for working with parent and child cases.

From the Clarify documentation:

The Enterprise Service Manager uses parent and child cases. With parent
and child cases, you can associate a group of problems with a common
cause. The parent case identifies the root cause. A child case is a customer
problem that arises due to the root cause and is linked to the parent case. A
child case differs from a Subcase, which is a way for subdividing a case for
parallel work by different employees on the same customer problem.

For example, suppose a WAN outage occurs within a company. Users create
multiple cases for sites affected by the outage. Using Service Manager, you
can designate one of the cases as the parent case and link the other related
cases to the parent case. Thereafter, updates on the outage are reported in the
parent case. Only one case needs to be updated, removing duplicate work.
All related child case owners can access the parent case window to view the
status.

The cctvtmmain utility closes all child cases of a parent case.

You can create a business rule that to close all child cases after a parent case is closed:

Rule Name: Close Child Cases
Object Type: Case
Start Event: Close Task
Conditions:
Parent Case Flag = 1

Action:
Action Name: Close Child Cases
Message Type: Command Line
Message:  cctvtmmain -case_id "[Object ID]"

OK, so now know what it is, and what its used for. Too bad its just so poorly named. I can guarantee you it was a programmer who came up with that POS name.

We also uncovered a bug in the cctvtmmain utility, in that it would throw an error if the parent case had both open and closed child cases. Since this is a compiled executable that we don’t have the source for, we can’t fix it. But we can easily rewrite it. A little PowerShell script should do the trick. Here’s the meat of the code:

$parentCaseId = [string] $args[0]

# Get the parent case (supercase)
   $dataSet = new-object FChoice.Foundation.Clarify.ClarifyDataSet($ClarifySession)
   $parentCaseGeneric = $dataSet.CreateGeneric("case")
   $parentCaseGeneric.AppendFilter("id_number", "Equals", $parentCaseId)
   $parentCaseGeneric.Query()
   if ($parentCaseGeneric.Rows.Count -eq 0){
      write-host
            write-host "Case ID $parentCaseId not found."  -backgroundcolor "red"
            write-host
         exit
   }
   $parentCaseObjid = $parentCaseGeneric.Rows[0]["objid"]

# Query for open children cases for the given parent case
   $childCaseGeneric = $dataSet.CreateGeneric("victimcase")
   $childCaseGeneric.AppendFilter("supercase_objid", "Equals", $parentCaseObjid);
   $childCaseGeneric.AppendFilter("condition", "Like", "Open");
   $childCaseGeneric.Query() 
     
# For each child case, close it
         foreach( $childCase in $childCaseGeneric.Rows){   
            $closeCaseResult = $supportToolkit.CloseCase($childCase["id_number"]);
         }

Pretty simple. Finally, change the business rule message to use our new script:

C:WINDOWSsystem32WINDOW~1v1.0powershell.exe C:pathCloseChildCases.ps1 "[Object ID]"

That’s it. We’ve just replaced a compiled, black box utility with a bug into a simple, open, working, script (with no known bugs).

It seems like I keep finding more and more easy ways to use PowerShell with our Dovetail SDK, and each one adds value to the system.

Rock on.