Using %Populate and Populate method
Hi-
I have created a class that extends %Persistent and %Populate and have set the various POPSPEC attributes of my properties to control how the properties are populated. However, when I compile the class and try to run the Populate() method it tells me the method isnt defined.
Here is the class definition:
Class My.PrimaryClass Extends (%Populate, %Persistent)
{
Property Name As %String(POPSPEC = "NAME");
Property Title As %String(POPSPEC = "TITLE");
Property City As %String(POPSPEC = "CITY");
Property State As %String(POPSPEC = "STATE");
Property Zip As %String(POPSPEC = "ZIP");
Property Employment As VA.SecondaryClass;
}However, when I run the Populate() method I get the following:
SAMPLES>do ##class(My.PrimaryClass).Populate(10000) DO ##CLASS(My.PrimaryClass).Populate(10000) ^ <METHOD DOES NOT EXIST>^My.PrimaryClass.1 *Populate,My.PrimaryClass SAMPLES>
I know this has to be somethng really simple that I am doing wrong here. Any ideas on why this might be happening?
This is: Cache for Windows (x86-64) 2016.1.1 (Build 108U) Wed Jul 6 2016 15:57:04 EDT
Comments
After further review and advice from others I have discovered that there are two problems.
1. The order of my inheritance needs to be switched to Extends (%Persistent, %Populate)
2. The POPSPEC attribute should actually point to a method name, ie: POPSPEC="Name()" and not POPSPEC="NAME" This was a problem with me mis-reading the documentation on POPSPEC.
I believe you have figured out the solution for this.
I have just mentioned below list of methods for different fields.
NAME - Name()
SSN - SSN()
COMPANY - Company()
TITLE - Title()
PHONE - USPhone()
CITY - City()
STREET - Street()
ZIP - USZip()
MISSION - Mission()
STATE - USState()
COLOR - Color()
PRODUCT - Product()
DocBook Link:
docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=GOBJ_populate