By now you’re aware of the availability of ORDA classes. In this blog post, you’ll learn a few handy tips to get the most out of them!
UsE strongly typed variables
You can strongly type your ORDA variables and take advantage of autocompletion thanks to the var keyword.
In the example below, $dataclass is typed as a dataclass class (cs.Students) and initialized with the Students dataclass object (ds.Students). Autocompletion automatically suggests:
- all of the functions defined at the dataclass level (new(), query(), etc.)
- all of the functions that you’ve implemented yourself in cs.Students (in this example: search())
Call functions dynamically
You’ve most likely used the [ ] notation to access the attributes of an object (e.g., $myObject[“propertyName”]). This is also possible with functions!
Here’s an example (psst …. don’t forget the ( ) at the end!):
There is a getDescription() function defined on the datastore class.
Class extends DataStoreImplementation
Function getDescription
C_TEXT($0)
$0:="Learning system covering "+String(This.Students.all().length)+" students"
It can be dynamically called like this:
C_TEXT($what;$functionName;$1)
$functionName:=$1
// $functionName can be "getDescription"
$what:=ds[$functionName]()