Written by

CEO at Ellipse
Question Pierre LaFay · Aug 3, 2023

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

Comments

Pierre LaFay · Aug 3, 2023

I make an error, my object is a %RegisteredObject

0
Julius Kavay · Aug 3, 2023

Two more bytes and the problem is solved:

Property refDate As%Date [InitialExpression = {$piece($horolog,",",1)}];//.............................................^......................^
0
Pierre LaFay  Aug 6, 2023 to Julius Kavay

Thanks Julius

I also found the %OnNew() method for consytructor of the object

0
Eduard Lebedyuk  Aug 6, 2023 to Pierre LaFay

InitialExpression would be preferable to %OnNew for predefined values.

%OnNew is for cases where you have user input.

0