How to initialize a new Object
Hi,
I try to initialize some properties of a %DynamicObject during his creation.
I Try to use InitialExpression this way :
Property refDate As %Date [InitialExpression = $piece($horolog,",",1)];
But it doesn't compile
I don't found if %DynamicObject can have a constructor to initialize properties by a calculated value, like other languages.
Product version: IRIS 2023.1
Discussion (4)0
Comments
I make an error, my object is a %RegisteredObject
Two more bytes and the problem is solved:
Property refDate As%Date [InitialExpression = {$piece($horolog,",",1)}];//.............................................^......................^Thanks Julius
I also found the %OnNew() method for consytructor of the object
InitialExpression would be preferable to %OnNew for predefined values.
%OnNew is for cases where you have user input.