Search code examples
intersystems-cacheintersystems

How to check if %ZEN.proxyObject has a property in Caché Object Script?


How to properly check that some %ZEN.proxyObject's object has a specific property?

In my case I have %ZEN.proxyObject instance. My guess is set p = $PROPERTY(object, "propertyName"). $PROPERTY returns an empty string if property does not exists, but what if the property value is an empty string?


Solution

  • Use %data property of %ZEN.proxyObject:

    Set obj = ##class(%ZEN.proxyObject).%New()
    Set obj.a = 2
    Write $Data(obj.%data("a"))
    >1
    Write $Data(obj.%data("b"))
    >0