Question
Keshav Iyer · Apr 11

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
1
0 142
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 (blah.foo, blah.bar);

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

}

Which produces output:

d ##class(DC.Demo.IndexOnSerialObject).RunDemo()
^DC.Demo.IndexOnSerialObjectD=1
^DC.Demo.IndexOnSerialObjectD(1)=$lb("",$lb("foo","bar"))
^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.