Written by

Head of Supply Chain Strategy at InterSystems
Question Ming Zhou · Jan 21, 2022

How to get all properties defined in a class from %Dictionary.ClassDefinition?

I am looking for a way to find all properties defined in any given class through coding, including those inherited from parent class(s). In case of inherited properties, I would like to know from which class etc.

A related question: XML adaptor provides a way to export xml schema for a class. Is there a similar method for JSON adaptor to generate a JSON schema for a class?

Thanks in advance for your help.

Product version: IRIS 2021.1

Comments

Timothy Leavitt · Jan 21, 2022

I'm not aware of any JSON schema capability.

%Dictionary has two sets of classes: *Definition and Compiled*. If you want to see inherited members you need to look at Compiled* (e.g., CompiledClass / CompiledProperty). If you want to know from which class, there's an "Origin" property.

0
Ming Zhou  Jan 21, 2022 to Timothy Leavitt

Thanks Timothy for the quick response. One thing I have not figured out is: regardless ClassDefinition or CompiledClass, their .Properties returns a relationshipObject. How do I get the set/array of PropertyDefinition associated with the class? Thanks.

0
Timothy Leavitt  Jan 21, 2022 to Ming Zhou

I'd run a query against %Dictionary.CompiledProperty where parent = (the classname)

0
Ming Zhou  Jan 21, 2022 to Timothy Leavitt

Thank you Timothy!

0