How can I open an object with dynamic class name and id?
Similar to: "set obj = ##class(myClass).%OpenId(id)", which give the an instance of the object with given ID, is there a way to implement a function/classmethod to return the same by providing both class name and ID as a parameter, such as: getObjectInstanceByNameId(className As %String, id As %Integer), using ObjectScript code?
Product version: IRIS 2021.1
$system.OBJ.OpenId(class,id)
$classmethod(class,”%OpenId”,id)
Thanks Dmitry!
One more way:
s myObj = ##class(%Persistent).%Open($lb(id,className))
Thanks Marc.
s result = ##class(%ZEN.Utils).%GetPropertyValue(myObj, propertyName, .value)
Is there another way to get the property value from myObj by providing the property name?
The only solution found is using %ZEN.Utils
w value
write $Property(myObj, propertyName)
Perfect. Thanks.
Thanks Marc!
Social networks
InterSystems resources
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue