Declare the property you need to use in the class, or remove the reference to the undefined property.
This check is not avoid for a instance of %Class.
Following code will compile, but on runtime the Set obj.test
will fail with "PROPERTY DOES NOT EXIST error" message.
Class Sample.NightWatch Extends %RegisteredObject
{
Property name As %String;
Property surname As %String;
Method CreateJon()
{
Set obj = ##class(Sample.Person).%New()
Set obj.name = "Jon"
Set obj.surname = "Snow"
Set obj.age = 27 // age is UNDEFINED
Return obj
}
}
Class Sample.NightWatch Extends %RegisteredObject
{
Property name As %String;
Property surname As %String;
Property age As %Integer;
Method CreateJon()
{
Set obj = ##class(Sample.Person).%New()
Set obj.name = "Jon"
Set obj.surname = "Snow"
Set obj.age = 27
Return obj
}
}