Skip to main content

Data types

Syntax rules

For the full lexical and parser rules each literal must follow (string escapes, map literal restrictions, list literal restrictions, etc.), see Syntax & Grammar.

In simple terms, if a variable is used to refer to stored data, the data type is used to refer to the type of data.

For a computer application, a number, a letter, and a date are all the same, a piece of information, or in other words, data. But different types of data cannot always react with each other. For example, it is illogical to multiply a number with a date. Since, in programming, there is often a need to perform operations between different types of data, there arises a need to differentiate between the types. And this is exactly the purpose of data types.

Data types define what type the given data is, and as a result, how the user can use the data.

The following data types are supported in Facilio Scripting.

String#

The text datatype represents a sequence of characters. Strings must be enclosed in double quotes — single quotes are a syntax error.

name = "David";

The only escape sequence is \" for an embedded double quote. Raw newlines inside a string are a syntax error — use + to concatenate multi-line text.

quoted = "He said \"go\".";greeting = "Hello," + " " + "World";

Number#

The Number datatype represents integer values. Number datatype can be used to perform operations with decimal values, in which case the end result becomes a decimal datatype.

age = 21;

Boolean#

The Boolean data type has one of two possible values: true or false. Lowercase onlyTrue / TRUE is a syntax error.

isactive = true;

Null#

null represents the absence of a value. fetchFirst and many other functions return null when there is no match — always null-check before accessing fields.

record = Module("workorder").fetchFirst([id == 1]);if (record != null) {    log record.subject;}

Map#

A map data type represents an unordered collection of key-value pair elements. Only the empty literal {} is allowed — populate via dot or bracket assignment afterwards. Populated literals like {name: "x"} are a syntax error.

asset = {};asset.name = "HVAC";asset.category = "Chiller";asset["warrantyExpiryTime"] = "July 21, 2021";
// Nested dot assignment is supportedm = {};m.a.b.c = "deep";

List#

List is a data type which can hold a collection of values. Each value in the list is called an element. A list can hold elements of different types (number, text, etc.) grouped together. The elements in a list are referenced by index.

colors = ["Red", "Yellow", "Green", "Orange"];empty = [];

Literal restriction: list literal elements must be atoms — string/number/boolean literals or plain variables. Arbitrary expressions like [a + 1, b * 2] are a syntax error. Build computed lists with .add().

// WRONGnums = [a + 1, b * 2];
// RIGHTnums = [];nums.add(a + 1);nums.add(b * 2);

There is also no nested literal indexing — assign the inner list to a variable first.

list1 = ["hello"];list2 = [list1];
// WRONGlog list2[0][0];
// RIGHTinner = list2[0];log inner[0];