Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The new Akioma Swat Client Logic API - CLAPI.

Below are some of the features that CLAPI introduces -:

  • Strong objectObject-oriented designprogramming.
  • Compile-time checking.
  • Intellisense and documentation.

...

https://code.visualstudio.com/docs/getstarted/introvideos

...

 

Migrating to the CLAPI

In the following example we will migrate a function to the CLAPI. The function gets the foreign keys (or initial field values) when launching a window to create a new record.

...

  1. Start by renaming (F2) the file and replacing the JavaScript .js file extension to the TypeScript .ts file extension.

    Now that the file is saved as a TypeScript file, you can see the compile errors and use the intellisense.

    The compile errors are marked with a red squiggly underline. Hover over the error to show the error messages.

    Lines with errors are marked in red on the side scroll bar. Files with errors are marked in red in the File Explorer.

    The intellisense and JSDoc comments opens automatically when typing object method and properties (starting when typing "." after an object).

    If the JSDoc comments are not shown together with the intellisense, click the blue circle with an "i" to show the JSDoc comments.

  2. 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 (namespaces are compiled into closures).

  3. Replace self with eventSource: 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.

  4. Replace getObject("CustomerDetailsForm") with getForm("CustomerDetailsForm")getObject("CustomerGrid") with getGrid("CustomerGrid") and container with window.

    The CLAPI supports generic traversing functions like getObject(), getLink() etc. which return the generic base SwatObject class object.

    The CLAPI also supports type specific function like getForm(), getGrid(), getRibbon() etc. to avoid casting.

    Alternatively you can use TypeScript casting. For example: (eventSource.getObject("MyForm") as akioma.swat.Form).

  5. Replace getValue with getDataValue.

    The Form and Grid classes have both a getScreenValue() and getDataValue() functions for getting the field screen value or record value respectively.

  6. Remember to save (Ctrl-S) your work (see picture below).

Documentation

In addition to the intellisense of the class methods, properties and their explanations

you can find the documentation for the complete list of CLAPI TypeScript classes, their methods and properties in the link below -below 

https://<your environment domain>/docs2

...

clapi-documentation.akiomacloud.de/


Calling JavaScript functions from TypeScript

...