How to use class property ot type %Persistent in non persistent class (page)
Is there a way to use a property of the type %Persistent class in a %ZEN.Component.page class?
Example:
// Data classClass PersistentClass Extends %Persistent
{
Property Value As%String;
}// Page classClass ClassName Extends%ZEN.Component.page
{
Property TestProperty As PersistentClass;
}
The problem is that when using it the described in the example.
The property can be set in a Method like this:
Method DoStuff() As %Status [ ZenMethod ]
{
Set result = ##class(HBS.EnsUtil.CompanyFunctions).GetData(.aVariable) // aVariable is of type PersistentClass
Set..TestProperty = aVariable
Quit result
}
But when reading the property in an other Method the content of it is not set:
Method ReadProperty() As %Status [ ZenMethod ]
{
Write ..TestProperty.Value // the object has no content
Quit$$$OK
}
Is it generally possible to work like this?
Or have I overlooked a special handling?
Comments
Hi !
It seems to work. Have you tried to look into the aVariable you get from the other company class (and check the type)?
I've tried to recreate your situation and all seems fine:.png)
.png)
@Ilenia Centonze
Hi!
Your solution looks good.
I will test it in my use case next week.
Thanks for your support👍
Hi,
it seems to work only in the console.
When I use it in the context of a page the property is filled in the first Method but not set in the second.
There are 2 server calls from the page and maybe they run in different tasks.