· Oct 26, 2023 2m read

How to get property definitions written in class programmatically

InterSystems FAQ rubric


Information on properties defined in a class can be obtained using the following system classes:



The code description example is as follows.

Class ISJ.Sample
ClassMethod getPropInfo(classname As %String)
    set cls=##class(%Dictionary.ClassDefinition).%OpenId(classname,,.status)
    if $$$ISERR(status) {
        write "Specified class does nt exist",!
    set x=cls.Properties
    for i=1:1:x.Count() {
        // Get property info (%Dictionary.PropertyDefinition)
        set prop=x.GetAt(i)
        if prop="" {
        set propname=prop.Name // property name
        set proptype=prop.Type // property type
        if propname="" {
        write propname," ",proptype,!

An example of execution is as follows.

USER>do ##class(ISJ.Sample).getPropInfo("Taxi.Driver")
DriverID %String
Name %String
Phone %String

Related article: How to get all fields of a specified table with SQL

Discussion (0)0
Log in or sign up to continue