Keshav Iyer · 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
0 182
Discussion (3)2
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)=""

@Vitaliy.Serdtsev thank you for pointing there! I couldn't find that via the new-and-improved (but still in progress) doc search and have provided feedback to that effect.

Side note: I love having the "Feedback" button on the right side in the docs, and it's great to see the amazing effort being put in to improving the docs, search, etc.