Andrew Neilson · Jan 8, 2020

Object Script equivalent to Studio "Find in Files"

I've been trying to figure out how to use an ObjectScript class to search other classes for specific strings.  To be very specific, I want to be able to search business rules to see if a particular DTL is in the rule.  We have some orphaned DTL's in our Ensemble productions and I want to make sure that they're not being used.



1 0 6 243
Log in or sign up to continue


Thank you, I'll keep that in mind.  That said, I still need the code solution because we won't be upgrading for several months.

Business rule classes store the rules as XML in an XData block with the name "RuleDefinition":

Class Demo.Rule.GenericRouter Extends Ens.Rule.Definition

Parameter RuleAssistClass = "EnsLib.MsgRouter.RuleAssist";

XData RuleDefinition [ XMLNamespace = "" ]
<ruleDefinition alias="" context="EnsLib.MsgRouter.RoutingEngine" production="TESTINGPKG.FoundationProduction">
<ruleSet name="" effectiveBegin="" effectiveEnd="">
<rule name="">
<when condition="1">
<send transform="Demo.DTL.Generic" target="Test.DummyOperation"></send>


One approach would be to find all of your business rule classes, retrieve the "RuleDefinition" XData block for each one, and then parse the XML to see which DTLs are called.

To find the business rule classes, have a look at %Dictionary.ClassDefinition. You could do a query like this to find your business rule classes:

select ID from %Dictionary.ClassDefinition where super='Ens.Rule.Definition'

Then, for each business rule class you can find the %Dictionary.XDataDefinition for the RuleDefinition XData block with a query like this:

select ID from %Dictionary.XDataDefinition where parent='Demo.Rule.GenericRouter' and name='RuleDefinition'

The raw XML from the XData block can be accessed via the stream object stored in the "Data" property of the %Dictionary.XDataDefinition row.

So far, it makes perfect sense.  The part I can't figure out is how to define the variable and actually get to the information.

Check for the following methods:

FindInFiles and FindInFilesRegex.

Optionally you could limit the search for a single project using the method FindInProject.

All methods belong to the %Studio.Project class.

Here's how Atelier does:

            Set tSC=##class(%Studio.Project).FindInFiles(
                "GENERATED="_generated, // filter

But you'll need to use device redirection to capture and parse its content. Because Studio uses these methods to display the results in the Output window.

Just the functionality I was looking for, including redirection