Creating Library Scripts

Library Scripts are accessed from the Library tab of the Scripting Center. Libraries can be called from both form and scheduled scripts. One library can call another library but circular relationships are not allowed. Libraries are automatically available when form and / or scheduled scripts are enabled, see Scripting Switches.

Library scripts are created in a similar way to form and scheduled scripts and follow the same Scripting Workflow.

Library scripts are not associated with a form or event and can only access NSOA.form functions if called from a form script.

References to libraries can be set from the Scripting Center Manage libraries or from the Scripting Studio Scripting Studio Tools and Settings.

To create a library script:

  1. Sign in as an Administrator and go to the Library tab on the Scripting Center.

    Note:

    Make sure you have the necessary switches enabled, see Scripting Switches.

  2. Create a new library script from the Create Button.

    Adding a new library script using the Create menu.

    You need to specify a unique filename for the script in the Dedicated Scripting Workspace. You can optionally select a document that already has the script you need otherwise an empty script file will be created. If you specify a document to upload then a new script file is created from the specified file and the original file left untouched.

  3. Click on the Script link in the Scripting Center to open the script in the Scripting Studio.

  4. Type the script into the editor.

    OpenAir Scripting Studio showin a library script example.

    Create functions in the same way as for form and scheduled script and then use exports to make the function available. You have the option to change the name of the function that is exported.

    Important:

    Functions created in a library are private to that library by default. You need to use the exports keyword to make the function available to scripts calling the library.

    Tip:

    If you don’t see a function you are expecting in the Functions Explorer check that the function has been exported and that the library does not contain any syntax errors.

  5. Fill out the fields in the Scripting Studio Tools and Settings:

    1. Select the user that the script will run for ‘In testing’ state, see Testing and Debugging.

    2. Select any libraries referenced by this library.

    3. Use the Code revision comments to comment the script changes made.

    4. Click SAVE.

    Note:

    The act of saving a script in the ”Inactive” state will move the script to the ”In testing” state, see Scripting Workflow.

    Important:

    You cannot deploy a script that references a library that is not deployed.

To use a library script:

  1. Create a form or scheduled script, see Creating Form Scripts.

  2. Reference the library either from the Scripting Center Manage libraries or from the Scripting Studio Tools and Settings.

  3. Use the library in the script.

    OpenAir Scripting Studio showin an example of form script referencing a library script.
    1. Use the require keyword to create a variable referencing the library.

    2. Use methods of the variable to access the functions exported by the library, see Objects.