Question
· Sep 21, 2016

Cache class Program

I get a input from user.How to I retrieve the data from these input. I enter the program but its occurred Some error .So give an idea of how to retrieve the data from properties.

ClassMethod Getvalue()
{
Details = ##class(Sample.Employeedetails).%New()
"Enter Your Name:" , Name1
Details.Name = Name1
"Enter Your Address :", Address1
Details.Address = Address1
"Enter your Phone Number:",Phonenumber1
Details.Phonenumber = Phonenumber1
"Enter your Blood Group:", Bloodgroup1
Details.Bloodgroup = Bloodgroup1
"Enter Your Desination:",Desiation1
Details.Desination = Desiation1
"Enter your Domain :",Domain1
Details.Domain = Domain1
status = Details.%Save()
}

ClassMethod PrintDetails()
{
##class(Sample.Employeedetails).#Name
}
 

Discussion (7)0
Log in or sign up to continue

You should actually read this tutorial.

Every class, has some types of elements, and some of them like Property and Parameter may contains some data.

Property stores data for every objects in this class, Parameter, for class itself.

In your example, saving data to properties of object was right. But in method PrintDetails, you try to read data from Parameter, not from property. To read data from property you should open this object before, but you also need to know an ID for such object.

#; open object by known ID
set obj=##class(Sample.Employeedetails).%OpenId(1)
#; if obj is empty, so this object could't be found, and open

#; ouptut property Name for this object
​Write !,obj.Name

in your code,

obj - it is some object, it may have some ID or not, if it just created

name1 - it is a value for property name in that object

but I completely don't understand why is here name2 and name3, and what do you suppose should be happens after this line ?

and how it should save data in other objects which we even don't know which ?

you should know somehow which objects you want to update. If you know only some other properties, you can use SQL command UPDATE