· Apr 11, 2022

Is it possible to add an index to a %SerialObject property?

I have a %Persistent class with properties that are of %SerialObject. I want to add an index to a property of the %SerialObject class.

Is this possible?

Product version: IRIS 2021.1
Discussion (3)1
Log in or sign up to continue

Yes. Here's a quick sample:

Class DC.Demo.SerialObject Extends %SerialObject

Property foo As %String;

Property bar As %String;


Class DC.Demo.IndexOnSerialObject Extends %Persistent

Property blah As DC.Demo.SerialObject;

Index blahFooBar On (,;

ClassMethod RunDemo()
    Do ..%KillExtent()
    Set inst = ..%New()
    Set = "foo"
    Set = "bar"
    Do inst.%Save()
    zw ^DC.Demo.IndexOnSerialObjectD,^DC.Demo.IndexOnSerialObjectI


Which produces output:

d ##class(DC.Demo.IndexOnSerialObject).RunDemo()
^DC.Demo.IndexOnSerialObjectI("blahFooBar"," FOO"," BAR",1)=""