...
TypeScript compiles to plain JavaScript. The compiled JavaScript code looks almost exactly the same as the TypeScript source code without the typings (when compiling to ES6 and beyond).
...
Replace
if (akioma.samples)
akioma.samples = {};akioma.samples.getOrderForeignKeys = function(self) {
With
namespace akioma.samples {
export function getOrderForeignKeys(self) {
Use namespaces to avoid naming conflicts. Note that functions must be exported to be used outside the namespace.
- Replace
self
witheventSource: akioma.swat.SwatObject
.
Note that the function parameter name does not have to be eventSource. For example: eventGrid eventForm, eventRibbon etc. Although self might be confusing with the JavaScript dynObject.
Note that the function parameter type does not have to be the generic base SwatObject as in this case. Use the correct Object Type class to avoid casting. - Replace
getObject("CustomerDetailsForm")
withgetForm("CustomerDetailsForm"),
getObject("CustomerGrid")
withgetGrid("CustomerGrid")
andcontainer
withwindow
.
The CLA supports generic traversing functions like getObject(), getLink() etc. which return the generic base SwatObject class object.
The CLA also supports type specific function like getForm(), getGrid(), getRibbon() etc. to avoid casting.
Alternatively you can use TypeScript casting. For example: (eventSource.getObject("MyObject") as akioma.swat.Form). - Replace
getValue
withgetDataValue
.
The Form and Grid classes have both a getScreenValue() and getDataValue() functions for getting the field screen value or record value respectively.
Save (Ctrl-S) and rename (F2) the file as Order/getOrderForeignKeys.ts using the .ts TypeScript file extension (see picture below).
Documentation
In addition to the intellisense of the class methods, properties and their explanation
you can find the documentation for the complete list of CLA TypeScript classes, their methods and properties in the link below -
https://<your environment domain>/docs2
Calling JavaScript functions from TypeScript
...