Skip to content

App

The App class (extends Record class) is the base class of all apps in the system. Even Container class is deriveD from App class. The App class is also a javascript representation of SYS$APP document class. The NavigationView (left tree in the Application Center) is populated with App class instances.

Constructor:

  • constructor(...parameters: any[])
    Created an App instance.

Methods:

  • run(): Promise
    Good practice is to initialize app in the constructor, but calling async methods is not advised in constructor. Therefore all async methods and display of UI elements should be done in run() method. For example: create a Page instance in constructor and call page.show() in run method.
  • runOnServer(args: AppArguments): Promise (static)
    It will make an app instance on the server, pass args parameter to app's constructor, and call run() method.
    Important: You must have Node Vision Command installed on the server machine.
  • close(handler?: ()=> boolean)
    Can be used to close an app (if the handler parameter is omitted). Alternatively, by supplying a handler function, you can listen for the app close event. If 'close' event returns false, app closing will be prevented. For example: you can use 'close' event to ask the user to save unsaved records/documents.
  • newInstanceAsync(args: AppArguments, pauseDebugger?: boolean):
    Important to understand, when selecting apps via App.SelectAsync() method, you will create a collection of App objects, but you cannot start an app using an App object. Remember, App class is just a base class for the actual app. That’s why we need this method.
    Hint: You should never use this method. Instead start an app like this:
    const {PropertiesApp} = await import('app:System.PropertiesApp');
    let instance = new PropertiesApp(ui.navigation.focused?.app); 
    instance.run();
    
  • click(handler?: ()=> boolean)
    Listen application UI control click events. Each control in the UI can fire a click event, If a control in its click event handler returns true (meaning event was handled), parent control will not receive the click event.
  • dblClick(handler?: ()=> boolean)
    Listen application UI control double-click events. Each control in the UI can fire a double-click event, If a control in its double-click event handler returns true (meaning event was handled), parent control will not receive the double-click event.
  • contextMenu(handler: ()=> Command[]):
    Listen application UI control right mouse click events. This handler enables you to add context menu items for all controls in the app.
  • keyDown(handler: (key: number, shift: boolean, alt: boolean, ctrl: boolean) => boolean)
    Listen application UI control key-down events. Each control in the UI can fire a key-down event, If a control in its key-down event handler returns true (meaning event was handled), parent control will not receive the key-down event.
    Example how to catch Ctrl+Enter key press
    this.keyDown((key, shift, alt, ctrl) => {  
        if (!shift && !alt && ctrl && key == 13) {      // Ctrl+Enter   
            // do something ;  
            return true; // handled   
        }  
        else if (!shift && !alt && ctrl && key == 83) { // Ctrl+S   
            // do something ;  
            return true; // handled   
        }  
    });
    
  • checkRight(right: string) (static)
    See Record checkRight() method

Properties:

  • id: string
    Unique identifier of the application instance.
  • creator: Grantee
    User created the application.
  • createdOn: Date
    Date and time the application was created.
  • modifier: Grantee
    User last modified the application.
  • modifiedOn: Date
    Date and time the application was last modified.
  • owner: Grantee
    Current owner of the application.
  • name: string
    The name of the application. This name is used internally to identify the app. For example, app named System.NewFileWizard can be created like this:
    const {NewFileWizard} = await import('nv:System.NewFileWizard');
    var app = new NewFileWizard();
    app.run();
    
  • label: string
    App label property is used in UI, for example in NavigationView
  • icon: string | Icon
    The icon assigned to the app (used in NavigationView together with label property). Value must be the name of an icon in SYS$ICON document class. The best practice is to use Icons.name_of_icon. You can add your own custom icons or change the existing ones via System Management→Icons app.
  • children: App[]
    App of type container (inherits class Container) can have one or many child apps.
  • parent: App
    This is your container app, or StartApp for apps on the root level in NavigationView.
  • views: View[]
    List of all active UI elements (View objects) current app instance holds.
  • commands: Command[] (static)
    Defines the context menu for this app in NavigationView. See Command class reference for examples.
  • instances: App[] (static)
    Retrieves all running instances of this exact app.
  • singleInstance?: boolean (static)
    Override this property in your app and return false if you want to prevent multiple instances of the app. This has no effect if app is instantiated from code.
  • type: ApplicationType
    The type of the application. Can be one of the following:
    • ApplicationType.Application
    • ApplicationType.Container
    • ApplicationType.Module
    • ApplicationType.UserControl
    • ApplicationType.UserTemplate
    • ApplicationType.ApplicationTemplate
    • ApplicationType.FileTemplate
    • ApplicationType.Web