Number of Subcases
The first example will simply return the total number of subcases for the current Case:
public class NumberOfSubcases : IPropertyFunction
{
public string Execute(TemplateContext context, IServiceLocator services)
{
var session = services.GetInstance<IClarifySession>();
var ds = session.CreateDataSet();
var caseObjId = (int) context.ObjectId;
// If it's an email log
if (context.ObjectType == 154)
{
var emailGeneric = ds.CreateGenericWithFields("email_log", "case_email2case");
emailGeneric.Filter(_ => _.Equals("objid", (int) context.ObjectId));
emailGeneric.Query();
if (emailGeneric.Count == 1)
caseObjId = emailGeneric.Rows[0].AsInt("case_email2case");
}
var generic = ds.CreateGenericWithFields("list_subcase", "id_number");
generic.Filter(_ => _.Equals("case_objid", caseObjId));
generic.Query();
return generic.DataRows().Count().ToString();
}
}
The code for this example is located in
src/Dovetail.PropertyExtensionExamples/Functions/NumberOfSubcases.cs
.
Number of Open Subcases
The first example will simply return the number of open subcases for the current Case:
public class NumberOfOpenSubcases : IPropertyFunction
{
public string Execute(TemplateContext context, IServiceLocator services)
{
var session = services.GetInstance<IClarifySession>();
var ds = session.CreateDataSet();
var caseObjId = (int)context.ObjectId;
// If it's an email log
if (context.ObjectType == 154)
{
var emailGeneric = ds.CreateGenericWithFields("email_log", "case_email2case");
emailGeneric.Filter(_ => _.Equals("objid", (int)context.ObjectId));
emailGeneric.Query();
if (emailGeneric.Count == 1)
caseObjId = emailGeneric.Rows[0].AsInt("case_email2case");
}
var generic = ds.CreateGenericWithFields("list_subcase", "id_number");
generic.Filter(_ => _.Equals("case_objid", caseObjId));
generic.Filter(_ => _.NotEqual("condition", "Closed"));
generic.Query();
return generic.DataRows().Count().ToString();
}
}
The code for this example is located in
src/Dovetail.PropertyExtensionExamples/Functions/NumberOfOpenSubcases.cs
.
Number of Child Cases
The first example will simply return the total number of child cases for the current Case:
public class NumberOfChildCases : IPropertyFunction
{
public string Execute(TemplateContext context, IServiceLocator services)
{
var session = services.GetInstance<IClarifySession>();
var ds = session.CreateDataSet();
var generic = ds.CreateGenericWithFields("victimcase");
generic.Filter(_ => _.Equals("supercase_objid", (int)context.ObjectId));
generic.Query();
return generic.DataRows().Count().ToString();
}
}
The code for this example is located in
src/Dovetail.PropertyExtensionExamples/Functions/NumberOfChildCases.cs
.
Number of Open Child Cases
The first example will simply return the number of open child cases for the current Case:
public class NumberOfOpenChildCases : IPropertyFunction
{
public static int ClosedStatus = 4;
public static int ClosedAdminPendingStatus = 68;
public string Execute(TemplateContext context, IServiceLocator services)
{
var session = services.GetInstance<IClarifySession>();
var ds = session.CreateDataSet();
var generic = ds.CreateGenericWithFields("victimcase");
generic.Filter(_ => _.Equals("supercase_objid", (int)context.ObjectId));
generic.Filter(_ => _.IsNotIn("clarify_state", ClosedStatus, ClosedAdminPendingStatus));
generic.Query();
return generic.DataRows().Count().ToString();
}
}
The code for this example is located in
src/Dovetail.PropertyExtensionExamples/Functions/NumberOfOpenChildCases.cs
.