Written by

Alenia B.V.
Question Marco Blom · Nov 21, 2017

how to write 'set ' for a property

Hello Community,

I have a simple question but somehow hard to find the solution:

this is a property in my class:

Property RelationAID As ZenCrm.Relationtypes;

this is my method to save:

ClassMethod PopulateMatrix(tvar1, tvar2) As %Status
{
set RelationMatrix=##class(ZenCrm.RelationMatrix).%New()
set RelationMatrix.RelationAID= tvar1
set RelationMatrix.RelationAType= tvar2
do RelationMatrix.%Save()
quit $$$OK
}

However the 'set' line does not work for the 'related properties.

I have tried: set RelationMatrix.Relationtypes.RelationAID but this failed.

Any suggestion? thanks!

Comments

Dan Pasco · Nov 21, 2017

To set a property whose type class is a serializable class (extends %Library.SwizzleObject - streams, serial classes, persistent classes) you need to call the property's SetObject or SetObjectId method if you wish to set the value to a serialized value (id value often). I think that in your example, tvar1 is holds an ID value of the referenced ZenCrm.Relationtypes class? If so, then this should work:

do RelationMatrix.RelationAIDSetObjectId(tvar)
0
Marco Blom  Nov 21, 2017 to Dan Pasco

Yes it does hold ID value's. Great it works! Thank you Daniel.

0