Flow Help
NovacuraRoadmap
6.12
6.12
  • What is Novacura Flow?
  • 📓System requirements
  • 🎉Release notes
    • Page 1
    • 6.12.2
  • 🎣Getting started
    • Quick start
    • Develop your first app
  • 🔨Installation and upgrade
    • Installation
    • New installation
    • Upgrade installation
    • Apply service pack
    • Add component
    • Windows authentication
    • Event log
    • FAQ
      • Monitoring
      • Troubleshooting
      • Migration tool
      • IIS user permission
      • Moving SQLite portal database
  • 🧱Security
    • Server
      • Security settings
  • 💡Development
    • Studio
      • Installation and log in
        • OpenID Connect
      • Applications
        • Menu
          • Inbox
            • Public variables
        • Workflow
          • Start step
          • User step
            • 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
            • Image selection input
            • Data grid
            • Calendar
            • List presentation
            • Camera input
            • File gallery
            • GPS location input
            • Signature capture input
            • Item creation sub task
            • Check list sub task
            • Verb sub task
          • Machine step
          • Decision step
          • Assertion step
          • Assignment
          • Table
          • Checkpoint
          • Split
          • Join
          • Script item
          • Log point
          • Annotation
          • End step
          • Included workflow
          • Offline resource
          • Swimlanes
          • Offline workflow
            • Create an offline workflow
            • Create an offline resource
            • Create an offline seed inbox
            • Create an offline transactions
        • Subscribe
        • Server content
          • Workflow scheduler
          • Generate link
        • Elements
        • Problems
        • Find
        • Metadata panel
        • Version panel
        • Navigation
        • Test bench
        • Application package
          • Get started
      • Environment
        • Users
        • Roles
        • Connectors
        • Properties
        • Languages
        • System events
        • Active directory sync
        • License
        • Devices
        • Branding
        • Reports
      • Monitoring
        • Tasks
        • Applications
        • Help requests
      • Connectors
        • Business systems
          • Database
          • IFS Applications
          • Infor M3
            • M3 Infor API
            • Infor M3 REST
          • Maximo Generic
          • SAP
            • SAP BAPI
              • Basic API
                • BAPI: ZNCFLOW_APPLICATION_COMPONENT
                • BAPI: BAPI_MONITOR_GETLIST
                • BAPI: BAPI_INTERFACE_GETDOCU
                • BAPI: RFC_GET_FUNCTION_INTERFACE
                • BAPI: ZNCFLOW_DDIF_FIELDINFO_GET
          • Oracle Primavera
          • Microsoft Dynamics AX
          • Microsoft Dynamics CRM
          • Microsoft Active Directory
          • Microsoft SharePoint 2013
            • Generic operations
              • Custom list
                • Attachments
                • Create new item
                • Create new item, with field values
                • Delete item
                • Get items by query
                • List all items
                • List fields of items
                • Update item field
              • Document library
                • Check in/out file
                • File management
                • Create sub folder
                • Upload/download
              • Tasks
                • Attachments
                • Predecessors
                • Task information
                • Update task
                • Create new subtask
                • Create new task
              • User operations
                • Group operations
                • Get user by ID
                • Get user by login name
                • List users
        • Communication
          • Email
          • Web page submit
          • FTP
            • Server Operations
            • Directory operations
            • Download Operations
            • File Operations
            • Upload operations
          • SFTP
            • Directory operations
            • Download operations
            • File operations
            • Upload operations
          • Modbus
            • Read operations
            • Write operations
          • External Oauth 2.0 provider
          • Siox
          • REST service
            • REST Project Tool
              • Getting started
              • Operations
                • Parameters
                  • Computed parameters
                • Outputs
              • Models
                • Custom model member
              • Model transform
              • Global output
              • Global parameters
              • Authorization schemes
              • Enumerations
              • Tools
          • Web service
            • Example
              • Webservice example: Connector to Microsoft Dynamics AX
        • Printing
          • BarTender 2016
            • Print
            • Manually select
            • Print from BTXML script
            • Print from BTXML script
            • List printers
          • NiceLabel
          • Html to PDF
        • Utility
          • Flow environment
          • Table Operations
          • Custom .NET
          • Google API
          • Generate Xml Data
          • Generate text
          • File System
            • Directory operations
            • File operations
            • Zip operations
      • FlowScript
        • Variables
        • Operators
        • Functions
          • Text functions
          • Number functions
          • Date functions
          • Advanced functions
        • Table
          • Table functions
        • Programs
        • Formats
        • Script examples
        • AD sync scripting
    • Portal 2
      • Getting started
      • General
        • Add pages and portlets
        • Edit pages
        • Navigation
        • Style
        • Settings
          • List of values management
          • Presentation mode
      • Portlets
        • Chart portlets
          • Column chart
          • Line chart
          • Pie chart
        • Data tree
        • Document viewer
        • Filter
        • Html table
        • KPI portlets
          • KPI card
          • Speedometer
        • Record viewer
        • Table
        • Text
        • Common configuration
    • Portal
      • Get started
      • Options
        • Settings
        • List of values management
        • Global variables management
        • Content access management
        • Translations management
        • Import/export
      • Portlets
        • Table
          • Database source
          • Workflow source
        • Record viewer
        • Process overview
        • Iframe
        • Inbox
        • News viewer
        • Document tree
        • Document list
        • Document viewer
        • Generic document viewer
        • Generic document viewer URL
        • Generic document viewer
        • Filter
        • HTML
        • Text
        • Data visualizer card
        • Data visualizer navigator
        • Visual planning
          • Gantt chart
          • Kanban
          • Resource bucket
          • Scheduler
        • Map
      • Icons
  • 📱Clients
    • Android legacy client
    • iOS client
    • Windows 10 client
    • Web client
    • Windows CE client
  • ❓FAQ
    • How do i find which version of Flow i am running?
  • 📧Contact
Powered by GitBook
On this page
  • Variable declarations
  • Return statement
  • Conditional statement
  • Loops
  • Table example
  • String example
  • Index loops
  • Type declarations
  • Automatic types
  • Function declarations
  • Errors
  • Parsing Example

Was this helpful?

  1. Development
  2. Studio
  3. FlowScript

Programs

In a Script Step you can use the full range of FlowScript statements.

Variable declarations

Variables are declared using the let keyword and re-assigned using the set keyword. Because FlowScript is an implicitly typed language, you cannot declare a variable without also assigning it.

let x = 12;  
set x = x + 1;  
// x is now 13 let

Return statement

To return a value from a FlowScript, use the return keyword. The Flow Designer checks to make sure that each branch of a FlowScript returns a value.

return x * 16;

Conditional statement

Conditional statements are written using the if/elseif/else keywords.

if quantity > 100 {
    let discountPercent = 10;
    let amount = quantity * price;
    return amount - (amount * (discountPercent/100));
}
else {
    return quantity * price;
}

When the body of a conditional clause consists of only one statement, it is possible omit the curly braces and use the colon (:) sign instead.

if x > 0:
    return "greater than zero";
elseif x < 0:
    return "less than zero";
else:
    return "zero";

Loops

Loops are written using the for and in keywords. You can loop over table variables, strings (one iteration per character in the string) and numerical ranges.

Table example

let items = [name: 'soda', price: 4.1] & [name: 'pizza', price: 8.9];
let totalPrice = 0;
for item in items {
    set totalPrice = totalPrice + item.price;
}

String example

let barcode = 'A123522BA12332';
let number_of_a = 0;
for c in barcode {
    if c = 'A':
        set number_of_a = number_of_a + 1;
}

In order to exit a loop prematurely, you can use the break; statement. In order to exit the current iteration and jump right into the next one, use the continue; statement.

If the body of a loop consists of only one statement, you can omit the curly braces and use the colon (:) sign instead.

for item in items:
    set totalPrice = totalPrice + item.price;

NOTE: To support backward compatibility with previous versions of Novacura Flow, the do and done keywords are also supported in lieu of the opening and closing curly braces.

Index loops

To loop over a range of indexes, use the range(start, count) function.

for i in range(0, 10) {
    // statements
}

Type declarations

It is possible to define types in FlowScript programs. A type defines the structure of a record (or table) variable. Types are defined like this:

type Person = [name, age];
// This creates a type named 'Person' with simple fields 'name' and 'age'.

When creating a new record based on a type, use the following syntax:

type Person = [name, age];
let donaldDuck = Person[name: 'Donald Duck', age: 35];

Types can have nested structures:

type Car = [model, year, engine: [power, torque]];
// This creates a type named "Car" with two simple fields (model and year) and a complex (record) field containing sub-fields "power" and "torque".
let myCar = Car[model: 'Volkswagen Golf', year: 2016, engine: [power: 170, torque: 184]];

Types can also refer to other types:

type Car = [model, year, engine: [power, torque]];
type personWithCar = [name, age, car: Car];

Types always define the structure of record variables. However, by adding the multiplier (*) unary operator, you can convert a type into the corresponding table type:

type Car = [model, year, engine: [power, torque]];
type PersonWithManyCars = [name, age, cars: *Car];

The multiplier (*) unary operator can also be used when initializing a record:

type Point = [x, y];
type DotGraph = [points: *Point];
let mySingleDotGraph = DotGraph[points: *[1, 1]];

It is possible to define default values for type fields. If a default value is given, the field does not have to be initialized.

type Customer = [name, email, phone = 'Not specified'];
let myCustomer = Customer[name: 'Acme Industries', email: 'info@acme.com'];
// myCustomer.phone will now be automatically initialized as 'Not specified'

It is possible to use nil values for type fields which themselves are records. nil values are only permitted for such cases; simple or table values cannot be nil.

type Employee = [name, salary, manager: Employee];
let anEmployee = Employee[
                    name: 'Bob',
                    salary: 10000,
                    manager: Employee[name: 'Alice', salary: 20000, manager: nil]
                ];


if not anEmployee.manager.manager = nil:
    error 'Didn't work';

Automatic types

Each record and table variable in a workflow can also be used as a type. This is useful when you need to programmatically create a record that matches the output from a machine step or some other workflow step. Automatic types are prefixed with the dollar sign ($). For record a variable myRecord, the automatically created type will be named $myRecord_type For a table variable myTable, the automatically created type will be named $myTable_rowtype.

let newRow1 = $myTable_rowtype[a: 1, b: 2];
let newRow2 = default($myTable_rowtype) with [b: 2];

Function declarations

Functions are declared using the let and function keywords.

let least = function(a, b) => {
    if a < b:
        return a;
    else:
        return b;
}

For a single-parameter function, no parentheses are needed around the argument list. For a single-statement bodied function, the curly braces, as well as the return keyword, can be omitted.

let square = function x => x * x;

If no parameter type is given for a function parameter, it is assumed to be a simple value. For complex values (records and tables), the syntax is similar to that of type definitions:

type Employee = [name, salary, position];
let employeesWorkingForFree = function(employees: *Employee) => {
    return employees where salary = 0;
}


let distance = function(point1: [x, y], point2: [x, y]) => {
    return sqrt(pow(point2.x - point1.x, 2) + pow(point2.x - point1.y, 2));
}

return distance([x: 3, y: 28], [x: 99, y: 0]);

If no return type is declared for a function, Flow tries to infer the return type based on the function body. It is also possible to specify an explicit return type.

type Employee = [name, salary, position];
let employeesWorkingForFree = function(employees: *Employee) : *Employee => {
    return employees where salary = 0;
}
// This function returns a table of Employee records

If recursion is required (i.e. a function that calls itself), return types MUST be explicitly specified. If such a function returns a simple value, the return type should be specified using the simple keyword.

let recursiveFunction = function(x) : simple => case when x > 10 then 999 else recursiveFunction(x + 1);

NOTE: To support backward compatibility with previous versions of Novacura Flow, the do and done keywords are also supported in lieu of the opening and closing curly braces.

Errors

If you need to raise an error from a FlowScript, use the error keyword.

error "This is the error message";

Parsing Example

The following FlowScript program example will take a table with one string column and parse it into a table with several columns. It will split columns based on a column delimiter and take the right side value by using a key-value delimiter.

let newTable = 
    [rowName:'id=1,price=10,name=Soda'] & 
    [rowName:'id=2,price=100,name=Burger'] & 
    [rowName:'id=3,price=50,name=Fries'];

let firstDelimiter = ',';
let secondDelimiter = '=';

let parseFunction = function(rowName, columnIndex, subColumnIndex) =>
    rowName.Split(firstDelimiter).Skip(columnIndex).First().value
        .Split(secondDelimiter).Skip(subColumnIndex).First().value;

return map newTable as 
    [id: parseFunction(rowName, 0, 1),
     price: parseFunction(rowName, 1, 1), 
     name: parseFunction(rowName, 2, 1)];
PreviousTable functionsNextFormats

Last updated 5 years ago

Was this helpful?

💡