REQUEST A DEMO

How to Automate a Workflow Process by Combining function based Rule Properties and the SDK Toolkit extension

workflow

When working with parent-child cases, a common workflow is to close the parent case when all the child cases have been closed.

We can easily automate this workflow using Dovetail tools and applications.

 

Business Rule

Here’s the rule that I want to create:

When the last child case is closed, close the parent case.

In order for this rule to function, I need to know when the last child case is closed.

I can do that by looking at the number of open child cases on the parent case. When this number is equal to zero, I know that all of the children have been closed.

But, out of the box, this number is not an available property.

But I can easily create my own, using the function-based rule property functionality.

 

 

NumberOfOpenChildCasesOnParent Rule Property

Following the examples, I can create my own function-based rule property.

Given the child case objid, I can query for the parent case objid, and then query to get the number of open child cases for this parent.

var childCaseGeneric = ds.CreateGenericWithFields("case", "case_victim2case");
childCaseGeneric.Filter(_ => _.Equals("objid", (int)context.ObjectId));
childCaseGeneric.Query();

if (childCaseGeneric.Count == 1)
    parentCaseObjId = childCaseGeneric.Rows[0].AsInt("case_victim2case");

var generic = ds.CreateGenericWithFields("victimcase");
generic.Filter(_ => _.Equals("supercase_objid", (int)parentCaseObjId));
generic.Filter(_ => _.IsNotIn("clarify_state", ClosedStatus, ClosedAdminPendingStatus));

generic.Query();

return generic.DataRows().Count().ToString();

 

That’s the meat of what needs to be done.

The complete code class is here: https://gist.github.com/gsherman/dfbdb2d7b382bec50e5340cc211cde4d

Notice that it’s a pretty small and simple block of code.

Following the instructions, I add my class, compile the assembly, drop it in the Rulemanager directory, and re-start Rulemanager.

Next, I need to create that as a rule property in the database, so it can be used by the business rule UI.

 

NumberOfOpenChildCasesOnParent Rule Property

Using Dovetail Agent, I create the new rule property, being sure to check the Is Function checkbox.

 

image

 

Now that I have the rule property defined, I can create my business rule, using that rule property as a condition.

 

Business Rule

Business Rule Events:

image

 

Business Rule Conditions:

Notice that I’m using NumberOfOpenChildCasesOnParent as a condition.

image

 

Business Rule Actions:

image

For the business rule action, notice that I’m sending Dovetail Carrier a CallToolkit message to invoke the CloseCase method within the Support toolkit.

I previously blogged about the SDK Toolkit extension in Dovetail Carrier, and how it makes it easy to invoke toolkit methods without writing any code.

Now we’re ready to test it out.

 

Test It

I have a child case, and I close it.

Looking at this child case, I can see that the Close Parent Case business rule fired:

child-case

 

Looking at the parent case, I can see that it was closed automatically by Dovetail Carrier:

parent-case

 

It all works just as expected!

 

Summary

What I like about this example is that I was able to combine two fairly new pieces of functionality:

to create an automated workflow process.

I was able to get this all going in under 15 minutes, which includes writing the code for the custom rule property.

That’s pretty awesome.

The specific example here (When the last child case is closed, close the parent case) is useful itself, but I think that the tools and techniques outlined here are even more valuable, demonstrating how you can extend the application suite and bend it to your will.

As another example, you could use this same process to automate closing a case when all of its subcases are closed.

As yet another example, see how a customer created a custom workflow using the SDK Toolkit extension in Dovetail Carrier.

Hopefully it’s starting to be clear as to how much power this opens up.

I’m looking forward to seeing what other ideas customers are able to implement using these tools and techniques.

Have an idea, or need some help? Leave a comment below, or drop me an email – I’m happy to help.

Rock on.

 

Dig This?

Sign up to get information like this delivered right to your inbox.