Formulas reference

Browse the built-in formulas in Nordcraft, which you can use to transform data, perform calculations, and implement conditional logic throughout your application.

Tip

To learn more about formulas, check out the formulas overview.

Absolute

Get the absolute value of a Number.

Arguments

Name Type Description
Value Number The input Number.

Output

Type Description
Number The absolute value of the input.

Add

Get the sum of multiple numbers.

Arguments

Name Type Description
0 Number Number to be added.
1 Number Number to be added.

Output

Type Description
Number The sum of all the input numbers.

Append

Add an element to the end of an Array.

Arguments

Name Type Description
Array Array The Array to append to.
Item Any The item to append to the Array.

Output

Type Description
Array A new Array containing all elements from the input Array, including the new item.

Boolean

Convert a value of any type to a Boolean.

Arguments

Name Type Description
Input Any Value of any type.

Output

Type Description
Boolean The input value converted to a Boolean. False and Null will return False, all other values will return True.

Branch Name

Get the name of the current branch. For production, the branch name is 'main'.

Output

Type Description
String Returns the name of the current branch.

Can Share

Return a Boolean indicating whether the provided data can be shared (with the "Share" action).

Arguments

Name Type Description
URL to share String
Title to share String
Text to share String

Capitalize

Capitalize a string: make the first letter uppercase whilst keeping the rest lowercase.

Arguments

Name Type Description
String String An input String.

Output

Type Description
String The capitalized String.

Clamp

Limit a value to a specified Min and Max value.

Arguments

Name Type Description
Value Number Number to round.
Min Number The smallest allowed Number.
Max Number The largest allowed Number.

Output

Type Description
Number Returns the input value if between the specified Min and Max. Otherwise, it returns the Min or Max value.

Concatenate

Concatenate two or more values.

Arguments

Name Type Description
0 Union

Output

Type Description
Union Returns a String or Array containing all the specified input values.

Current URL

Return the current URL of the browser. Use the "Parse URL" formula for working with the URL.

Output

Type Description
String The browser's current URL.

Date From String

Convert a string to a Date.

Arguments

Name Type Description
Date string String A String representing a date, for example "January 1, 1970".

Output

Type Description
Date The input value converted to a Date.

Date From Timestamp

Convert a timestamp (milliseconds) to a Date.

Arguments

Name Type Description
Timestamp Number A Number in milliseconds since 1st January, 1970 (EPOCH).

Output

Type Description
Date The input value converted to a Date.

Decode URI Component

Decode a URI component that was previously encoded with the Encode URI Component formula.

Arguments

Name Type Description
EncodedURI String The encoded URI to decode.

Output

Type Description
String The decoded URI component.

Decode base64

Deocde a base64 string to utf-8.

Arguments

Name Type Description
Base64 value String The input data encoded as base64.

Output

Type Description
String The decoded string.

Default to

Return the first value that is not False or Null.

Arguments

Name Type Description
0 Any The inital value.
1 Any The first fallback value to be used if the primary value is Null or False.

Output

Type Description
Any Returns the first value that is not False or Null. Returns Null if no valid values is given.

Delete

Return a copy of the input Object or Array without the specified key.

Arguments

Name Type Description
Object Object The input record
Path Union The path can be either a Number (if the first argument is an array), a String, or an Array of strings. If an Array is given, the property at that path will be removed.

Output

Type Description
Object A copy of the record without the property specified in the Path.

Divide

Perform a division calculation.

Arguments

Name Type Description
Dividend Number The number to be divided.
Divisor Number The number to divide by.

Output

Type Description
Number The result of dividing the dividend with the divisor.

Drop

Remove items from the beginning of an Array or String.

Arguments

Name Type Description
Array Union Input array
Count Number of items to remove.

Output

Type Description
Union A copy of the list without the first items.

Drop last

Remove item(s) from the end of an Array or String.

Arguments

Name Type Description
Array Union Input array
Count Number Number of items to remove.

Output

Type Description
Union A copy of the list without the last item(s).

Encode JSON

Encode data as JSON.

Arguments

Name Type Description
Data Any The data to convert.
Indent Number How many characters the encoded value will be indented.

Output

Type Description
String The encoded JSON value.

Encode URI Component

Encode a URI component, escaping certain characters to their UTF-8 representation.

Arguments

Name Type Description
URIComponent String The URI component to encode.

Output

Type Description
String The encoded URI component.

Encode to base64

Encode a string to base64.

Arguments

Name Type Description
Value String The input string to be encoded.

Output

Type Description
String The base 64 encoded string.

Entries

Get an Array of entries from a given Object.

Arguments

Name Type Description
Object Object Input record

Output

Type Description
Array Returns an Array of entries for the given input record.
The entries are Objects with a “Key” and “Value” property.

Equals

Compute if values are identical.

Arguments

Name Type Description
First Any First Value
Second Any Second Value

Output

Type Description
Boolean Returns True if the input values are identical, otherwise False.

Every

Run a formula returns for all items in an Array.

Arguments

Name Type Description
Array Array The array of items to evaluate.
Formula Formula Predicate formula for evaluating each item.

Output

Type Description
Array Returns True if the predicate formula returns true for all items in the Array, otherwise False.

Filter

Return a new Array containing only the elements for which the provided formula evaluates to True.

Arguments

Name Type Description
Array Array The array of items to be filtered.
Formula Formula Predicate formula for filtering items.

Output

Type Description
Array New Array containing only the items for which the Formula evaluated to True.

Find

Search through an Array of items and apply a formula to each item, to return the first item where the provided formula returns True.

Arguments

Name Type Description
Array Array The array to search through
Formula Formula The predicate formula that each item in the array is passed to.

Output

Type Description
Any The first item in the Array where the formula returns True. Returns Null if the predicate formula did not return True for any item.

Find Last

Search through an Array of items and apply a formula to each item, to return the last item where the formula returns True.

Arguments

Name Type Description
Array Array The array to search.
Formula Formula The predicate formula that each item in the Array is passed to.

Output

Type Description
Any The last item in the Array where the formula returns True. Returns Null if the predicate formula did not return True for any item.

Find index

Search through an Array of items and apply a formula to each item, to return the index of the first item where the formula returns True.

Arguments

Name Type Description
Array Array The array to search.
Formula Formula The predicate formula that each item in the Array is passed to.

Output

Type Description
Any The index of the first item in the Array where the predicate formula returns True. Returns -1 if the predicate formula did not return True for any item.

First

Return the first item in an Array.

Arguments

Name Type Description
Array Array An Array of items.

Output

Type Description
Any The first item in the Array.

Flatten

Flatten a nested Array.

Arguments

Name Type Description
Array Array An Array containing one or more Arrays.

Output

Type Description
Array A flattened Array where all items in the original array are concatenated.

Format Date

Format a date using the Intl.DateTimeFormat API. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat for more information.

Arguments

| Name | Type | Description |
| --------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Date | Date | Date to format |
| Locale(s) | String | Array | Optional locale to use for formatting the Date, e.g. "en" or "fr". Multiple locales can be provided (as an Array of Strings) to provide a fallback locale. The default value is the runtime's locale. |
| Options | Object | Optional Object for configuring the formatting of the output. See
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat#syntax for all options. |

Output

Type Description
String The Date input formatted as a String.

Format Number

Format a Number using the Intl.NumberFormat API. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat for more information.

Arguments

| Name | Type | Description |
| --------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Input | Number | Number to format. |
| Locale(s) | String | Array | Optional locale to use for formatting the Number, e.g. "en" or "fr". Multiple locales can be provided (as an Array of Strings) to provide a fallback locale. The default value is the runtime's locale. |
| Options | Object | Optional Object for configuring the formatting of the output. See
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#locale_options for all options. |

Output

Type Description
String The Number input formatted as a String.

From entries

Create a record from an Array of entries.
This formula is the reverse of Entries.

Arguments

Name Type Description
Array Array The array of entries.

Output

Type Description
Object An Object containing all entries from the input Array.

Get

Extract a value from an Object, Array or String at the specified path.

Arguments

Name Type Description
Object Union The Object, Array or String you want to extract an item from.
Path Union The Path can be either a Number, a String, or an Array.

Output

Type Description
Any The value found at the Path. If no value is found, this value of the output is Null.

Get element by id

Return a DOM element with a given id.

Arguments

Name Type Description
Id String The id of the DOM element to return.

Output

Type Description
Element The DOM element with the given id. If no DOM element is found, this will return Null.

Get from Local Storage

Read a value from local storage with the provided key.

Arguments

Name Type Description
Key String The key to read from local storage.

Output

Type Description
Any The value found in local storage. If no value is found, this will return Null.

Get from Session Storage

Read a value from session storage with the provided key.

Arguments

Name Type Description
Key String The key to read from session storage.

Output

Type Description
Any The value found in session storage.

Greater or equal

Compute whether a value is larger than or equal to another value.

Arguments

Name Type Description
First Number First value to be compared.
Second Number Second value to be compared.

Output

Type Description
Boolean Returns True if the first Number is larger than or equal to the second Number.

Greater than

Compute if a value is larger than another value.

Arguments

Name Type Description
First Number First value to be compared.
Second Number Second value to be compared.

Output

Type Description
Boolean Returns True if the first Number is larger than the second Number.

Group by

Group an Array of items into an Object based on a grouping formula.

Arguments

Name Type Description
Array Array Array of items to be grouped.
Formula Formula The grouping formula used to group the items. The String returned from the formula will match the key in the output Oject.

Output

Type Description
Object An Object where each key matches a value returned by the grouping formula, and each value is the list of items that share the return value.

Includes

Test if an Array or String includes a specific item or value.

Arguments

Name Type Description
Array Union The Array to search.
Item Any The item or value to search for.

Output

Type Description
Boolean Returns True if the item or value exists in the Array or string. Returns False if no match is found.

Index of

Find the index of a specific item in an Array or String.

Arguments

Name Type Description
Array Union The Array or String to search.
Item Any The items to search for.

Output

Type Description
Number If the item exists in the Array, the index of that item is returned. If the item is not found, -1 is returned.

Is Server

Get information about whether formulas are currently evaluated server-side or client-side.

Output

Type Description
Boolean Returns True if formulas are evaluated server-side, and False if formulas are evaluated client-side.

JSON

Convert a value into a JSON String.

Arguments

Name Type Description
Input Any The input value.
Indentation Number The number of spaces used for indentation in the JSON String.

Output

Type Description
String The JSON String.

Join

Combine an Array of Strings in to a single String.

Arguments

Name Type Description
Array Array An array of Strings.
Separator String A separator String that is inserted in between each item in the Array to join.

Output

Type Description
String A String combining each item in the input Array separated by the separator String, e.g. joining ["a", "b", "c"] with a "," separator will return "a,b,c".

Key by

Organize an Array of items into an Object based on a Key formula.

Arguments

Name Type Description
Array Array Array of items.
Formula Formula The key formula used to index the items. The String returned from the formula will match the key in the output Object.

Output

Type Description
Object An Object where each key matches a value returned by the key formula, and each value is the item that String was returned for.

Languages

An array of the preferred languages for the user, based on the Navigator.languages property (on the client) or the Accept-Language header (on the server).

Output

Type Description
Array An array with the preferred languages for the user.

Last

Get the last item in an array

Arguments

Name Type Description
Array Array The input Array.

Output

Type Description
Any The last item in the Array.

Last Index of

Search an Array or String to find the index of the last occurrence of a specified item or substring.

Arguments

Name Type Description
Array Union The Array or String to search.
Item Any The item or substring to search for.

Output

Type Description
Number If the item or substring exists in the Array, the last index of that item is returned. If the item is not found, -1 is returned

Less or equal

Compute if a value is smaller than or equal to another value.

Arguments

Name Type Description
First Number First Number to be compared.
Second Number Second Number to be compared.

Output

Type Description
Boolean Returns True if the First Number is smaller than or equal to the second Number, otherwise it returns False.

Less than

Compute if a value is smaller than another value.

Arguments

Name Type Description
First Number First Number to be compared.
Second Number Second Number to be compared.

Output

Type Description
Boolean Returns True if the First Number is smaller than the second Number, otherwise it returns False.

Logarithm

Return the logarithm of a Number.

Arguments

Name Type Description
Number Number A Number greater than or equal to 0.

Output

Type Description
Number The natural logarithm of the Number.

Lower case

Convert a string to lowercase.

Arguments

Name Type Description
String String Input String

Output

Type Description
String The input String with all characters converted to lowercase.

Map

Run a formula on each item of an Array to return a new Array.

Arguments

Name Type Description
Array Array The Array of items.
Formula Formula The formula to run on each item of the Array.

Output

Type Description
Array A new Array containing all the values returned from running the provided formula on each item in the provided input Array.

Matches

Finds the (global) matches in a String based on a regular expression.

Arguments

Name Type Description
Input String The string to search for matches in.
Regular expression String The regular expression to use for matching.
Global search Boolean Test the regular expression against all possible matches in a string.
Case insensitive Boolean Ignore case while attempting a match in a string.
Multi line Boolean Treat multiline strings as multiple lines.

Output

Type Description
Array An Array of Strings

Max

Find the largest Number from a list of inputs.

Arguments

Name Type Description
0 Number Input Number.
1 Number Input Number.

Output

Type Description
Number The largest of the input Numbers.

Min

Find the smallest Number from a list of inputs.

Arguments

Name Type Description
0 Number Input number
1 Number Input number

Output

Type Description
Number The smallest of the input Numbers.

Minus

Subtract a Number from a Number.

Arguments

Name Type Description
Minuend Number The number to subtract from.
Substrahend Number The number to subtract.

Output

Type Description
Number The result of subtracting the Substrahend from the Minuend.

Modulo

Get the remainder when dividing two Numbers.

Arguments

Name Type Description
Dividend Number The number to be divided.
Divider Number The number to divide by.

Output

Type Description
Number The remainder when the Dividend is divided by the Divider.

Multiply

Multiply two or more Numbers.

Arguments

Name Type Description
0 Number Number to be multiplied.
1 Number Number to be multiplied.

Output

Type Description
Number The product of multiplying the input Numbers.

Not

Get the Boolean opposite of an input value.

Arguments

Name Type Description
Input Boolean The input value.

Output

Type Description
Boolean Returns True if the input value is False, and False if the input value is True.

Not equal

Compute if values are not identical.

Arguments

Name Type Description
First Any First value.
Second Any Second value.

Output

Type Description
Any Returns True if the values are not identical, otherwise False.

Now

Get a Date representing "Now"

Output

Type Description
Date A Date object initialized at the current date/time.

Number

Convert a value of any type to a Number.

Arguments

Name Type Description
Input Any Value of any type

Output

Type Description
Number The input value converted to a Number.

Parse JSON

Parse a String to JSON.

Arguments

Name Type Description
JSON string String The String to be parsed.

Output

Type Description
Any The parsed JSON value. If the input is not a valid String, this returns Null.

Parse URL

Parse a URL

Arguments

Name Type Description
URL String The URL value to parse.
Base String An optional base for the URL. Use this to resolve relative URLs.

Output

Type Description
Object An object containing: "hostname", "searchParams", "path", "hash", "href", "protocol", "port", "origin"

Power

Raise a number to a power.

Arguments

Name Type Description
Base Number The number to be raised to the exponent.
Exponent Number The exponent to raise the base to.

Output

Type Description
Number The result of raising the base to the exponent.

Prepend

Add an element to the start of an Array.

Arguments

Name Type Description
Array Array The Array to prepend to.
Item Any The item to prepend to the Array.

Output

Type Description
Array A new Array containing the new item and all the elements from the input Array.

Random number

return a random Number between 0 and 1.

Output

Type Description
Number A random Number between 0 and 1.

Range

Create an Array of numbers between a Min and Max value.

Arguments

Name Type Description
Min Number The smallest value in the list.
Max Number The largest value in the list.

Output

Type Description
Array An Array containing all the numbers between Min and Max, inclusive.

Reduce

Reduce a group of items to a single value by applying each item to a reducer formula.

Arguments

Name Type Description
Array Union The Array or Object of items to be reduced.
Formula Formula The reducer formula. Each item in the Array is applied to the formula along with the accumulator. The result of this formula will be a new accumulator used for the next item.
Accumulator Any The initial value of the accumulator. This value is passed to the reducer formula along with the first item in the Array, and the result is used as the accumulator for the next item.

Output

Type Description
Any The value returned from applying the last item to the reducer formula.

Replace all

Replace all occurrences of a substring in a String.

Arguments

Name Type Description
Input The input string to search in.
Search The substring to search for.
Replace with The replacement value.

Output

Type Description
The resulting String.

Reverse

Reverse the order of an Array.

Arguments

Name Type Description
Array Array The Array to be reversed.

Output

Type Description
Array The reversed Array.

Round

Round a Number to the nearest decimal point.

Arguments

Name Type Description
Input Number Number to round.
Decimals Number Number of decimals to round to.

Output

Type Description
Number The rounded Number.

Round down

Round a Number down to the nearest decimal point.

Arguments

Name Type Description
Input Number Number to round down.
Decimals Number Number of decimals to round to.

Output

Type Description
Number The rounded Number.

Round up

Round a Number up to the nearest decimal point.

Arguments

Name Type Description
Input Number Number to round up.
Decimals Number Number of decimals to round to.

Output

Type Description
Number The rounded Number.

Set

Set a value in an Object or Array based on a specified path.

Arguments

Name Type Description
Object Object The input Object.
Path Union The Path can be either a Number, a String or an Array of Strings.
Value Any The value to set.

Output

Type Description
Object The input Object with the new field.

Shuffle

Shuffle items in an Array or String.

Arguments

Name Type Description
Array Union Input Array or String.

Output

Type Description
Union The shuffled Array or String.

Size

Get the size of an Array, Object or String.

Arguments

Name Type Description
Collection Union The collection to get the size of.

Output

Type Description
Number The size of the collection.

Some

Run a formula on all items of an Array to determine if any item matches a set of conditions.

Arguments

Name Type Description
Array Array The Array of items to evaluate.
Formula Formula Predicate formula for evaluating each item.

Output

Type Description
Boolean Returns True if the predicate formula returns True for any items in the Array, otherwise False.

Sort by

Sort an Array using a formula.

Arguments

Name Type Description
Array Array The input Array.
Formula Formula The sorting formula. The output of this formula will determine the sort order of the items. If the formula returns an Array, the items will first be sorted by the first item, then the second, etc.
Ascending? Boolean Should the list be sorted in ascending order?

Output

Type Description
Number The input Array sorted by the value returned by the sorting formula.

Split

Split a String into an Array of smaller strings each time a delimiter occurs. The delimiter will not be part of the output

Arguments

Name Type Description
Input String The String to split.
Delimiter String The string to split by.

Output

Type Description
Array An array of Strings.

Square root

Get the square root of a Number.

Arguments

Name Type Description
Number Number The input Number.

Output

Type Description
Number The square root of the input Number.

Starts with

Check if a String has a given prefix.

Arguments

Name Type Description
String String The String to check.
Prefix String The prefix to check for.

Output

Type Description
Boolean Returns True if the input String starts with the prefix, otherwise False

String

Convert a value of any type to a String.

Arguments

Name Type Description
Input Any Value of any type.

Output

Type Description
String The input value converted to a String

Sum

Return the sum of an Array of numbers

Arguments

Name Type Description
Array Array The array of numbers to sum.

Output

Type Description
Number The total sum from adding all the numbers in the Array.

Take

Take items from the start of an Array or String.

Arguments

Name Type Description
Array Union Input Array or String.
Count Number Number of items to take.

Output

Type Description
Union The first items from the Array or String.

Take last

Take items from the end of an Array or String.

Arguments

Name Type Description
Array Union Input Array or String.
Count Number Number of items to take.

Output

Type Description
Union The last items from the Array or String.

Timestamp

Get the timestamp from a Date, e.g. 1633462980000.

Arguments

Name Type Description
Date Date The date to get the timestamp from.

Output

Type Description
Number The timestamp from the date input.

Trim

Remove any leading and trailing white spaces from a String.

Arguments

Name Type Description
String String The String to trim.

Output

Type Description
String The trimmed String.

Type of

Get the type of a given input.

Arguments

Name Type Description
Input Any The input value.

Output

Type Description
Any The type of the input value. Types can be one of: String, Boolean, Number, Array, Object, or Null.

Unique

Remove duplicate values from an Array.

Arguments

Name Type Description
Array Array The input Array.

Output

Type Description
Array The input Array with all duplicate values removed.

Uppercase

Convert a String to uppercase.

Arguments

Name Type Description
String String Input String.

Output

Type Description
String The input String with all characters converted to uppercase.

User Agent

Get the user agent for the browser or from the User-Agent header on the server

Output

Type Description
String The user agent string.
05/07/2025
Edit article
Help Forum