Written by

Senior Cloud Architect at InterSystems
Question Eduard Lebedyuk · Mar 2, 2019

Get concrete class from id

I have one abstract class and several subclasses. All share one data/id global.

How can I get concrete class name from id (without opening the object)?

What I have so far:

write $p($lg(^DATAGLOBAL(<id>),1),"~",*-1)

It does the job, but is there a more official way?

Comments

Robert Cemper · Mar 2, 2019

OID contains the class name. So this should do it.

write $li(##class(Abstract.Class).%ComposeOid(id),2)

0
Eduard Lebedyuk  Mar 4, 2019 to Robert Cemper

Thank you Robert. That's exactly what I was searching for.

0
Robert Cemper · Mar 2, 2019

I just realized that this method doesn't check the existence of the ID.

therefore:

write:##class(Abstract.Class).%ExistsId(id) $li(##class(Abstract.Class).%ComposeOid(id),2)

or any equivalent construct.

0