Question
Joseph Tsang · Jun 27

Populate object by %LoadFromMemory()

Has anyone here been successfully populating a %Persistent object from calling %LoadFromMemory() with a temp. global?

I have tried using Sample.Person in the SAMPLES namespace. It worked EXCEPT that I have no way to set the id into that Sample.Person objec.

SAMPLES>Merge array(1) = ^Sample.PersonD(1)
 
SAMPLES>Set obj = ##class(Sample.Person).%LoadFromMemory(1,.array)
 
SAMPLES>zw obj
obj=1@Sample.Person  ; <OREF>
+----------------- general information ---------------
|      oref value: 1
|      class name: Sample.Person
| reference count: 2
+----------------- attribute values ------------------
|       %Concurrency = 1  <Set>
|                DOB = 32008
|               Name = "Jaynes,Will W."
|                SSN = "996-40-3910"
+----------------- swizzled references ---------------
|   i%FavoriteColors = ""  <Set>
|   r%FavoriteColors = ""  <Set>
|             i%Home = $lb("4693 Maple Drive","Albany","SD",10333)  <Set>
|             r%Home = ""  <Set>
|           i%Office = $lb("3989 First Drive","Miami","KS",76548)  <Set>
|           r%Office = ""  <Set>
|           i%Spouse = ""
|           r%Spouse = ""
+--------------- calculated references ---------------
|                Age   <Get>
+-----------------------------------------------------
 
SAMPLES>Write obj.%Id()
 
SAMPLES>
SAMPLES>Do obj.%IdSet(1)
 
DO obj.%IdSet(1)
^
<PRIVATE METHOD>
SAMPLES>Write obj.%Id()
 
SAMPLES>

 

Product version: IRIS 2020.1
0
0 57
Discussion (1)1
Log in or sign up to continue

Default Samples.Person use the implicit ID.

You need to change or  write your own Method %IdSet or Define your own property as  ID