Written by

Developer at pagero gmbh
Question PagerianDevelper · Mar 17

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?

Product version: IRIS 2021.1

Comments

Ilenia Centonze · Mar 18

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:

0
PagerianDevelper  Mar 28 to PagerianDevelper

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.

0