· Jun 23

Class Parameters Usage in DTL

Hi, Developers!

I wonder if it is possible to use class parameters in DTL XData?

E.g. in an example below of the DTL I'd prefer to setup ChatGPT prompts in parameters (GPTPrompt1) of DTL rather than quotes inside the XData XML:

If possible, how can I refer to a class parameter from XData?

Thanks in advance!

Product version: IRIS 2023.1
Discussion (2)1
Log in or sign up to continue

Hi Evgeny,

The function $Parameter in conjunction with $This, to access these.

For example:

value='$Parameter($This, "[Parameter Name]")'

For example adding to Stream example yesterday.

Vanilla Source class.

Class Test.Str2Stream.ExampleIn Extends (%Persistent, %XML.Adaptor)
Property Filename As %String;
Property Content As %String;

DTL class. Where the magic happens:

Class Test.Str2Stream.Trans Extends Ens.DataTransformDTL [ DependsOn = (Test.Str2Stream.ExampleIn, Ens.StreamContainer) ]
Parameter Salutation = "YeaBuddy";
Parameter Reaction = "LightWeight";
Parameter REPORTERRORS = 1;
XData DTL [ XMLNamespace = "" ]
<transform sourceClass='Test.Str2Stream.ExampleIn' targetClass='Ens.StreamContainer' create='new' language='objectscript' >
<assign value='##class(Test.Str2Stream).StringToStream(source.Content,source.Filename)' property='target.Stream' action='set' />
<assign value='target.Stream.WriteLine($Parameter($This,"Salutation"))' property='x' action='set' />
<assign value='target.Stream.WriteLine("These plates are "_$Parameter($This,"Reaction"))' property='x' action='set' />

Testing In:

  <Content>The session begins...

Testing output: