Flow Connect Help
Roadmap
  • â„šī¸This is Flow Connect
    • Overview
    • Technical overview
      • System requirements
    • What's new?
      • Change log
  • â–ļī¸quick start
    • Create an application
    • Create an admin access group
  • 🔁working with Connect
    • Connect to systems
      • Connector agents
        • Add agent group
        • Install agent manager
        • Add agent
        • Manage agent
      • Connectors
        • IFS Applications 10
        • Oracle
        • Microsoft SQL Server
        • Send Email
        • REST
          • Microsoft Graph API
          • Infor M3 REST
            • Obtaining Infor ION API file
            • Configure REST Connector with ION API file
          • IFS Cloud
            • IAM Client Registration
            • Obtaining end-point info from IFS Cloud
            • Configure REST Connector for IFS Cloud
        • File System
      • Redirect URIs
    • Create and design
      • Application packages
      • Applications
        • Create
        • Design
        • Test
        • Commit
      • Portal Pages
        • Create Portal Page
        • Design Portal Page
        • Commit Portal Page
      • Components
        • Create component
        • Manage component
      • Modules
        • Create module
        • Manage module
      • Automations
        • Functionality
        • Create Automation
        • Manage Automation
        • Creating Access Key
        • Executing Automations Externally
          • IFS Cloud
          • Salesforce Apex Trigger Example
    • Deploy
      • Environments
      • Deploy
    • Use
      • On mobile devices
      • In web browser - Web client
      • In web browser - Portal
    • Share
      • Share Applications
    • User administration
      • Users
        • Invite a new user
        • Manage users
      • User groups
        • Create user groups
        • Manage user groups
      • Access
        • Manage access
  • â¸ī¸Reference
    • How-to guides
      • Create User Step controls
        • Header
        • Static text
        • Labelled static text
        • Link
        • Image viewer
        • Text input
        • Numeric input
        • Date input
        • Time input
        • Check box input
        • Binary option input
        • List selection input
        • List multi-selection input
        • Menu selection input
        • Data grid
        • Calendar control
        • Image selection input
        • List presentation
        • Camera Input
      • Dependent controls in User step
        • Variable source
        • Expression source
        • Control visibility (condition to hide)
      • Configure SSO for Microsoft Entra
    • Reference
      • Clients
        • Settings
        • My data
      • Designer
        • Controls
          • Header
          • Static text
          • Labeled static text
          • Link
          • External app launcher
          • Image viewer
          • Text input
          • Numeric input
          • Date input
          • Time input
          • Check box input
          • Binary option input
          • List selection input
          • List multi-selection input
          • Menu selection input
          • Data grid
          • Calendar
          • Image selection input
          • List presentation
          • Camera input
          • File gallery
          • GPS location input
          • Signature capture input
          • Item creation sub task
          • Check list sub task
          • Verb sub task
        • Steps
          • Start
          • User interaction
          • External system
          • Decision
          • Assertion
          • HTTP requests
          • Assignment
          • Table
          • Event listener
          • Checkpoint
          • Script
          • Annotation
          • End
          • Local data resource
      • Portal
        • Design items
          • Portlets
            • Accumulation chart
            • Base chart
            • Circular gauge
            • Custom content
            • Data tree
            • Document viewer
            • Filter
            • Kanban
            • KPI card
            • Link
            • My apps
            • Record
            • Rich text
            • Table
          • Container
          • Common portlet configuration
            • General
            • Events
            • Data
            • Custom buttons
            • Style
        • Portal settings
          • Branding
          • Page
          • Navigation
        • Profile
        • Portlet actions
        • Cache
        • Input to Start Step
      • Diagnostic mode
      • FlowScript
        • Walkthrough
          • Introduction
          • Expressions and programs
          • Anatomy of a program
          • Variables
          • Simple types
          • Nullable types
          • Records
          • Sequences
          • Other types
          • Arithmetic
          • Other expressions
          • Queries
          • Conditionals and loops
          • Function definitions
          • Built-in functions
          • DateTime module
          • Seq module
          • HTTP module
          • CSV module
          • JSON module
          • Trace module
          • Record module
          • XML Module
          • Filesystem Module
          • Custom modules
          • Custom Types
          • Appendix: Subtyping rules
          • Appendix: Escape sequences
          • Appendix: Type checking errors
      • Flowscript Copilot
      • Glossary
    • Flow Connect Downloads
      • Install Flow Connect Designer
    • Migrate from Flow Classic
      • Portal - migrate from Flow Classic
      • Classic vs. Connect Comparison Guide
Powered by GitBook
On this page
  • Modules
  • Assertions
  • Private
  • FlowScript Playground

Was this helpful?

  1. Reference
  2. Reference
  3. FlowScript
  4. Walkthrough

Custom modules

PreviousFilesystem ModuleNextCustom Types

Last updated 1 year ago

Was this helpful?

Modules

A module is a named library of reusable functions, types and values. You can from the Hub and consume them in your applications.

Modules are only allowed to declared functions, types and values.

// This code may be placed in a module. We will call it MyModule.

// A function which reverses a text value.
function reverse(input: text) {
    let result = "";
    for c in input {
        set result = c & result;
    }
    return result;
}

// A value containing some placeholder text.
let placeholderText = "Lorem ipsum";

Given such a module, we can use it in a script step:

// In a script step in an application
// which refers to MyModule by dragging it onto the canvas:

return MyModule.reverse(MyModule.placeholderText); // Returns "muspi meroL";

Assertions

While developing a module, it is often useful to investigate the behavior of its functions before consuming them in an application. You can do this using assertions.

An assertion is a statement indicating what you expect to be true about a function. Similar to a unit test in other programming environments, an assertion can be checked while the code is being developed.

// In a module named "MyModule"

function reverse(input: text) {
    let result = "";
    for c in input {
        set result = c & result;
    }
    return result;
}

// A couple of assertions defining the behavior of the reverse function.
assert reverse("abc") == "cba";
assert reverse("a") == "a";
assert reverse("") == "";

To check the assertions in a module, press the Check Assertions button above the module editor. Assertions which evaluate to true are considered successful; assertions which evaluate to false (or raise a runtime error) are considered failed. The success or failure of each individual assertion will be indicated by a green check mark or a red cross, respectively, next to the line.

When applications are run, assert statements are ignored.

Making use of assertions is a highly recommended practice, as they help verify that the code in the modules retains its expected behavior as you continue to work on it.

Private

Functions and values in modules can be marked as private. A private function or value can be used by other functions and values inside the module but are not visible to applications that use the modules.

A private function or value is declared by adding the private keyword before the function or let keywords.

// Declare a private email validation regex pattern.
private let emailPattern = @"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$";

// Declare a public email validation function
function isValidEmail(candidate: text) => regexMatch(candidate, emailPattern);

// Assertions are never visible from outside and do not need to be marked as private.
assert isValidEmail("info@novacura.com");
assert not isValidEmail("info.novacura.com");

FlowScript Playground

All modules that are open in the Designer are automatically made available in the FlowScript Playground. The Playground will use the current version of the module, regardless of whether it is saved.

â¸ī¸
create your own modules