Written by

Question Ali Chaib · Feb 28, 2020

Create a list of messages in studio

Do you have any clue how to create a list of messages in studio ?

Example :

I can define one message that is called DoctorInfoMsg such as 

set DoctorInfoMsg= ##class(PKGNotification.InDoctorInfo).%New()

 

Where PKGNotification.InDoctorInfo is composed of 

Property UserName As %String;

Property ListOfPatients As list Of %String;

 

How to define a list of PKGNotification.InDoctorInfo messages ?

How to get UserName of the first message?

Comments

Eduard Lebedyuk · Feb 28, 2020

Working with collection properties documentation.

If you want to hold a list of objects at runtume, use %ListOfObjects.

If you want to store a list of objects use collection properties (as you use ListOfPatient).

0
Ali Chaib  Feb 28, 2020 to Eduard Lebedyuk

Thank you Eduard.

To clarify, I don't have a problem with defining the properties in a message.

My question is how to define a list of messages. What's the syntax ?

Unfortunately, I couldn't find my answer in this documentation.

I want something similar to 

set mylist=##class(%ListOfDataTypes).%New()

But instead of ListOfDataTypes I want List of DoctorInfoMsg

Thanks again :) 

0
Eduard Lebedyuk  Feb 28, 2020 to Ali Chaib
Property DoctorInfos As list Of PKGNotification.InDoctorInfo;

?

0
Ali Chaib  Mar 2, 2020 to Eduard Lebedyuk

Thank you so much 

0
Peter Steiwer · Feb 28, 2020

Hi Ali,

Here is a sample of using %ListOfObjects:

SAMPLES>set list=##class(%ListOfObjects).%New()
 
SAMPLES>set t1=##class(HoleFoods.Transaction).%OpenId(1)
 
SAMPLES>d list.Insert(t1)
 
SAMPLES>w list.Count()
1
SAMPLES>set t2=##class(HoleFoods.Transaction).%OpenId(2)
 
SAMPLES>d list.Insert(t2)
 
SAMPLES>w list.Count()
2
SAMPLES>w list.GetAt(1)
2@HoleFoods.Transaction
SAMPLES>w list.GetAt(1).%Id()
1
SAMPLES>w list.GetAt(2).%Id()
2
SAMPLES>w list.GetAt(2).AmountOfSale
6.95

0
Ali Chaib  Mar 2, 2020 to Peter Steiwer

Thank you so much.

Creating a list of objects instead of list of a specific type of messages is a good option

0