How to set reference on property of class type

Code snippet, Caché

Hi,

I have a working import routine, but I do get an error on properties based on another class

in this case [OrgType As ZenCrm.OrgType].

How do i set the correct reference?

Thanks

  • 0
  • 0
  • 181
  • 3
  • 1

Answers

You can do it either this way:

set OrgTypeId = $piece(line, ",", 2) // assuming, item 2 is an OID of ZenCrm.OrgType
if ##class(ZenCrm.OrgType).ExistsId(OrgTypeId) { set rec.OrgType = ##class(ZenCrm.OrgType).%OpenId(OrgTypeId,0) }

or this way:
do rec.OrgTypeSetObjectId($piece(line, ",", 2))

Thank you Julius, it works perfect!

I choose : do rec.OrgTypeSetObjectId($piece(line, ",", 2))

Thanks Eduard, useful information!