25.01.2015 Views

Using Caché Objects - InterSystems Documentation

Using Caché Objects - InterSystems Documentation

Using Caché Objects - InterSystems Documentation

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

OnPopulate<br />

20.12 OnPopulate<br />

This instance method is called by the Populate method after assigning values to an object's<br />

properties but before the object is saved to disk. This method provides additional control over<br />

the generated data. If an OnPopulate method exists, then the Populate method calls it for<br />

each object that it generates.<br />

Its syntax is:<br />

ReturnValue %OnPopulate()<br />

where:<br />

ReturnValue<br />

A %Status code, where a failure status causes the instance being<br />

populated to be discarded.<br />

For example, if you have a stream property, Memo, and wish to assign a value to it when<br />

populating, you can provide an OnPopulate method:<br />

Method OnPopulate() As %Status<br />

{<br />

Do ..Memo.Write("Default value");<br />

QUIT $$$OK<br />

}<br />

This method is available to the %Library.Populate class and its subclasses. See the chapter<br />

The <strong>Caché</strong> Data Population Utility for more information on data population generally.<br />

<strong>Using</strong> <strong>Caché</strong> <strong>Objects</strong> 177

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!